Spacy
을 사용하여 Parse Tree
을 인쇄하고 싶습니다. 그러나 아래의 코드는 오류를 제공하고 있습니다TypeError : Spacy Python에서 'module'객체를 호출 할 수 없습니다.
en_nlp = spacy.language('English') TypeError: 'module' object is not callable
오류는 en_nlp = spacy.loads('en')
에 있습니다. 나는 from spacy.en import English
을 가져옴으로써 en_nlp = spacy.language(English)
으로 털어 내려고했지만 여전히 작동하지 않습니다. 누군가 도울 수 있습니까?
코드 :
import spacy
from nltk import Tree
en_nlp = spacy.loads('en')
doc = en_nlp("The quick brown fox jumps over the lazy dog.")
def to_nltk_tree(node):
if node.n_lefts + node.n_rights > 0:
return Tree(node.orth_, [to_nltk_tree(child) for child in node.children])
else:
return node.orth_
[to_nltk_tree(sent.root).pretty_print() for sent in doc.sents]
오류로 인해 'spacy.language'는 호출 가능한 메소드가 아닌 모듈입니다 –
's '가없는 spacy.load ('en ')를 사용해보십시오 – mpurg
@mpurg's '없이는 여전히 작동하지 않습니다. – user6750923