どのバージョンをお使いですか? lower
で、それが私のために正しく動作:lower
なし
>>> doc = nlp(u'Algorithms; Deterministic algorithms; Adaptive algorithms; Something...'.lower())
>>> for word in doc:
... print(word.text, word.lemma_, word.tag_)
...
(u'algorithms', u'algorithm', u'NNS')
(u';', u';', u':')
(u'deterministic', u'deterministic', u'JJ')
(u'algorithms', u'algorithm', u'NNS')
(u';', u';', u':')
(u'adaptive', u'adaptive', u'JJ')
(u'algorithms', u'algorithm', u'NN')
(u';', u';', u':')
(u'something', u'something', u'NN')
(u'...', u'...', u'.')
、鬼はAlgorithms
タグNNP、すなわち固有名詞を割り当てます。このモデルは、単語が固有名詞であると統計的に推測しているため、これを避けることができます。
tokenizerにspecial caseのルールを設定して、spaCyにAlgorithms
という名前が決して適切な名詞ではないことを伝えることができます。
from spacy.attrs import POS, LEMMA, ORTH, TAG
nlp = spacy.load('en')
nlp.tokenizer.add_special_case(u'Algorithms', [{ORTH: u'Algorithms', LEMMA: u'algorithm', TAG: u'NNS', POS: u'NOUN'}])
doc = nlp(u'Algorithms; Deterministic algorithms; Adaptive algorithms; Something...')
for word in doc:
print(word.text, word.lemma_, word.tag_)
(u'Algorithms', u'algorithm', u'NNS')
(u';', u';', u':')
(u'Deterministic', u'deterministic', u'JJ')
(u'algorithms', u'algorithm', u'NN')
(u';', u';', u':')
(u'Adaptive', u'adaptive', u'JJ')
(u'algorithms', u'algorithm', u'NNS')
(u';', u';', u':')
(u'Something', u'something', u'NN')
(u'...', u'...', u'.')
tokenizer.add_special_case
機能を使用すると、文字の文字列をトークン化する方法を指定し、サブトークンのそれぞれの属性を設定することができます。
おかげで、私はこの問題はスペイシーのバージョンによって引き起こされるかもしれないと思う、私は1.5.0にスペイシー1.3.0を更新することでこの問題を解決します。 –