重新训练Spacy依赖模型失败

时间:2017-10-11 08:36:54

标签: python-3.6 spacy

当我尝试重新训练spacy英语模型时,正如我在示例中所发现的那样,它失败了:

Python 3.6.2 (v3.6.2:5fd33b5926, Jul 16 2017, 20:11:06) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import spacy
>>> from spacy.tokens import Doc
>>> from spacy.gold import GoldParse
>>> 
>>> nlp = spacy.load('en')
>>> doc = Doc(nlp.vocab, words=['Who', 'is', 'Shaka', 'Khan', '?'])
>>> gold = GoldParse(doc, [(1, 'nsubj'), (1, 'ROOT'), (3, 'compound'), (1, 'dobj'), (1, 'punct')])
>>> nlp.parser(doc)
>>> gold
<spacy.gold.GoldParse object at 0x114008a58>
>>> nlp.parser.update( doc, gold )
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "spacy/syntax/parser.pyx", line 320, in spacy.syntax.parser.Parser.update (spacy/syntax/parser.cpp:10286)
  File "spacy/syntax/arc_eager.pyx", line 357, in spacy.syntax.arc_eager.ArcEager.preprocess_gold (spacy/syntax/arc_eager.cpp:7888)
AttributeError: 'NoneType' object has no attribute 'upper'

我在这里做错了什么?任何帮助表示赞赏。

1 个答案:

答案 0 :(得分:0)

由于Ghislain PUTOIS(@ghpu)在spacy支持聊天室回答我,该文档似乎有点过时,而是https://github.com/explosion/spaCy/blob/master/examples/training/train_parser.py,现在金头和deps已分开。