HanLP icon indicating copy to clipboard operation
HanLP copied to clipboard

和elasticsearch2.3.4集成后报错

Open why633630 opened this issue 10 years ago • 9 comments

用1.2.5和es2.3.4集成后,插入es数据和测试es分词效果时报如下错误: { "error" : { "root_cause" : [ { "type" : "no_class_def_found_error", "reason" : "no_class_def_found_error: Could not initialize class com.hankcs.hanlp.seg.common.Vertex" } ], "type" : "no_class_def_found_error", "reason" : "no_class_def_found_error: Could not initialize class com.hankcs.hanlp.seg.common.Vertex" }, "status" : 500 }

堆栈为:

Caused by: NotSerializableExceptionWrapper[no_class_def_found_error: Could not initialize class com.hankcs.hanlp.seg.common.Vertex] at com.hankcs.hanlp.seg.common.WordNet.(WordNet.java:71) at com.hankcs.hanlp.seg.Viterbi.ViterbiSegment.segSentence(ViterbiSegment.java:40) at com.hankcs.hanlp.seg.Segment.seg(Segment.java:422) at com.hankcs.hanlp.seg.common.wrapper.SegmentWrapper.next(SegmentWrapper.java:62) at com.hylanda.hanlp.plugin.HanlpTokenizer.incrementToken(HanlpTokenizer.java:101) at org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction.simpleAnalyze(TransportAnalyzeAction.java:247) at org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction.shardOperation(TransportAnalyzeAction.java:225) at org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction.shardOperation(TransportAnalyzeAction.java:63) at org.elasticsearch.action.support.single.shard.TransportSingleShardAction$ShardTransportHandler.messageReceived(TransportSingleShardAction.java:282) at org.elasticsearch.action.support.single.shard.TransportSingleShardAction$ShardTransportHandler.messageReceived(TransportSingleShardAction.java:275) at org.elasticsearch.transport.TransportRequestHandler.messageReceived(TransportRequestHandler.java:33) at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:75) at org.elasticsearch.transport.netty.MessageChannelHandler$RequestHandler.doRun(MessageChannelHandler.java:300) at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) 请问Vertex这个类初始化的时候是不是有操作文件的代码?我怀疑是权限问题

why633630 avatar Aug 22 '16 13:08 why633630

Vertex本身不读文件,但里面有:

public static Vertex B = new Vertex(Predefine.TAG_BIGIN, " ", new CoreDictionary.Attribute(Nature.begin, Predefine.MAX_FREQUENCY / 10), CoreDictionary.getWordID(Predefine.TAG_BIGIN));

请检查配置文件,或者使用portable版。

hankcs avatar Aug 22 '16 13:08 hankcs

嗯,再问下,hanlp的日志输出怎么配置呢?和es集成后一直看不到hanlp本身的日志...谢谢!

why633630 avatar Aug 22 '16 14:08 why633630

HanLP本身的日志只作为调试用,在生产环境中不建议打开。

有兴趣的话可以com.hankcs.hanlp.utility.Predefine#logger或Logger.getLogger("HanLP");拿到日志,然后做你想做的。

hankcs avatar Aug 22 '16 15:08 hankcs

谢谢,我试试,感觉配置没有问题,可能是es权限控制的问题

why633630 avatar Aug 23 '16 01:08 why633630

LZ你好,我最近也想试着学习将hanlp集成到elasticsearch中,请问有什么可以参考的教程么?

yukiknight026 avatar Sep 09 '16 03:09 yukiknight026

thanks all

why633630 avatar Oct 28 '16 03:10 why633630

请问有事 集成成功了啊,我也遇到 一楼 一样的问题。

chenruiSundun avatar Mar 09 '17 08:03 chenruiSundun

麻烦@yayawcx 有空帮帮他们

hankcs avatar Mar 09 '17 19:03 hankcs

感谢您对HanLP1.x的支持,我一直为没有时间回复所有issue感到抱歉,希望您提的问题已经解决。或者,您可以从《自然语言处理入门》中找到答案。

时光飞逝,HanLP1.x感谢您的一路相伴。我于东部标准时间2019年12月31日发布了HanLP1.x在上一个十年最后一个版本,代号为最后的武士。此后1.x分支将提供稳定性维护,但不是未来开发的焦点。

值此2020新年之际,我很高兴地宣布,HanLP2.0发布了。HanLP2.0的愿景是下一个十年的前沿NLP技术。为此,HanLP2.0采用TensorFlow2.0实现了最前沿的深度学习模型,通过精心设计的框架支撑下游NLP任务,在海量语料库上取得了最前沿的准确率。作为第一个alpha版本,HanLP 2.0.0a0支持分词、词性标注、命名实体识别、依存句法分析、语义依存分析以及文本分类。而且,这些功能并不仅限中文,而是面向全人类语种设计。HanLP2.0提供许多预训练模型,而终端用户仅需两行代码即可部署,深度学习落地不再困难。更多详情,欢迎观看HanLP2.0的介绍视频,或参与论坛讨论。

展望未来,HanLP2.0将集成1.x时代继承下来的高效率务实风范,同时冲刺前沿研究,做工业界和学术界的两栖战舰,请诸君继续多多指教,谢谢。

hankcs avatar Jan 01 '20 10:01 hankcs