def getNer(text):
with open('chunker.pkl', 'rb') as pickle_file:
chunker = pickle.load(pickle_file)
return chunker.parse(pos_tag(word_tokenize(text)))
运行这个函数很好 但是当我在Django项目中包含这个函数时 我得到以下错误
^{pr2}$被酸洗的对象是
class NamedEntityChunker(ChunkParserI):
def __init__(self, train_sents, **kwargs):
assert isinstance(train_sents, Iterable)
self.feature_detector = features
self.tagger = ClassifierBasedTagger(
train=train_sents,
feature_detector=features,
**kwargs)
def parse(self, tagged_sent):
chunks = self.tagger.tag(tagged_sent)
iob_triplets = [(w, t, c) for ((w, t), c) in chunks]
return conlltags2tree(iob_triplets)
我使用的是最新版本的Django和Python3
我也有同样的错误-结果是我在试图打开类之前没有导入它。在能够读取对象之前,GUI需要知道如何构造对象。尝试:
在调用函数之前。在
相关问题 更多 >
编程相关推荐