1
我定期收到AttributeError: 'Synset' object has no attribute 'lower'
。我的代碼,都在同一個文件,生成錯誤:如何用Python/NLTK/Wordnet避免一個不起眼的錯誤信息?
Synset('book.n.01')
[Synset('book.n.01')]
Traceback (most recent call last):
File "./map", line 124, in <module>
print print_nodes(word)
File "./map", line 98, in print_nodes
result.append(print_nodes(synonym), indentation_level + 2 *
File "./map", line 88, in print_nodes
synonyms = wordnet.synsets(root)
File "/usr/local/lib/python2.7/site-packages/nltk/corpus/reader/wordnet.py", line 1416, in synsets
lemma = lemma.lower()
AttributeError: 'Synset' object has no attribute 'lower'
初始值似乎是我的本意,Synset('book.n.01')
。當它運行時,它似乎正在運行一旦想到鄰居Wordnet拉起,但這是一個單獨的問題。
觸發'Synset' object has no attribute 'lower'
的問題是什麼,如何解決?