在此行中定义了括号中的拆分,在括号中的拆分在两个字母之间进行了拆分:
https://github.com/explosion/spaCy/blob/23ec07debdd568f09c7c83b10564850f9fa67ad4/spacy/lang/de/punctuation.py#L18
没有简单的方法来删除中缀模式,但是您可以定义一个自定义标记器,该标记器可以执行您想要的 *** 作。一种方法是从中复制并定义中缀
spacy/lang/de/punctuation.py:
import reimport spacyfrom spacy.tokenizer import Tokenizerfrom spacy.lang.char_classes import ALPHA, ALPHA_LOWER, ALPHA_UPPER, CONCAT_QUOTES, LIST_ELLIPSES, LIST_IConSfrom spacy.lang.de.punctuation import _quotesfrom spacy.util import compile_prefix_regex, compile_infix_regex, compile_suffix_regexdef custom_tokenizer(nlp): infixes = ( LIST_ELLIPSES + LIST_ICONS + [ r"(?<=[{al}]).(?=[{au}])".format(al=ALPHA_LOWER, au=ALPHA_UPPER), r"(?<=[{a}])[,!?](?=[{a}])".format(a=ALPHA), r'(?<=[{a}])[:<>=](?=[{a}])'.format(a=ALPHA), r"(?<=[{a}]),(?=[{a}])".format(a=ALPHA), r"(?<=[{a}])([{q}][])(?=[{a}])".format(a=ALPHA, q=_quotes), r"(?<=[{a}])--(?=[{a}])".format(a=ALPHA), r"(?<=[0-9])-(?=[0-9])", ] ) infix_re = compile_infix_regex(infixes) return Tokenizer(nlp.vocab, prefix_search=nlp.tokenizer.prefix_search, suffix_search=nlp.tokenizer.suffix_search, infix_finditer=infix_re.finditer, token_match=nlp.tokenizer.token_match, rules=nlp.Defaults.tokenizer_exceptions)nlp = spacy.load('de')nlp.tokenizer = custom_tokenizer(nlp)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)