运行书本第八章的条件随机场进行命名实体识别的代码,在这里
def test(recognizer):
analyzer = AbstractLexicalAnalyzer(PerceptronSegmenter(), PerceptronPOSTagger(), recognizer)
results = analyzer.analyze("华北电力公司董事长谭旭光和秘书胡花蕊来到美国纽约现代艺术博物馆参观")
print(results)
scores = Utility.evaluateNER(recognizer, PKU199801_TEST)
Utility.printNERScore(scores)
总是报jpype._jclass.java.lang.NullPointerException: None
我追踪了一下,是因为这一部分:
CRFNERecognizer = JClass(‘com.hankcs.hanlp.model.crf.CRFNERecognizer’)
AbstractLexicalAnalyzer = JClass(‘com.hankcs.hanlp.tokenizer.lexical.AbstractLexicalAnalyzer’)
PerceptronSegmenter = JClass(‘com.hankcs.hanlp.model.perceptron.PerceptronSegmenter’)
PerceptronPOSTagger = JClass(‘com.hankcs.hanlp.model.perceptron.PerceptronPOSTagger’)
Utility = JClass(‘com.hankcs.hanlp.model.perceptron.utility.Utility’)
CRFNERecognizer 和 AbstractLexicalAnalyzer 报下面的错误,才导致指针为空的。
AttributeError(‘Field is not static\n\tat PyJPField::get(native\python\pyjp_field.cpp:115)\n\tat PyJPField::get(native\python\pyjp_field.cpp:122)\n’)
请问上述问题大家都是怎么解决的?