HanLP icon indicating copy to clipboard operation
HanLP copied to clipboard

运行TestSegment.java 测试类中的 testShortest、testNT方法 出现以下错误

Open yuchaozhou opened this issue 11 years ago • 3 comments

版本为当前最新1.1.5 java.lang.ExceptionInInitializerError at com.hankcs.hanlp.recognition.ns.PlaceRecognition.roleTag(PlaceRecognition.java:106) at com.hankcs.hanlp.recognition.ns.PlaceRecognition.Recognition(PlaceRecognition.java:36) at com.hankcs.hanlp.seg.Viterbi.ViterbiSegment.segSentence(ViterbiSegment.java:75) at com.hankcs.hanlp.seg.Segment.seg(Segment.java:242) at com.hankcs.test.seg.TestSegment.testShortest(TestSegment.java:71) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at junit.framework.TestCase.runTest(TestCase.java:168) at junit.framework.TestCase.runBare(TestCase.java:134) at junit.framework.TestResult$1.protect(TestResult.java:110) at junit.framework.TestResult.runProtected(TestResult.java:128) at junit.framework.TestResult.run(TestResult.java:113) at junit.framework.TestCase.run(TestCase.java:124) at junit.framework.TestSuite.runTest(TestSuite.java:232) at junit.framework.TestSuite.run(TestSuite.java:227) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:131) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) Caused by: java.lang.ArrayIndexOutOfBoundsException: -1 at com.hankcs.hanlp.collection.trie.DoubleArrayTrie.get(DoubleArrayTrie.java:1210) at com.hankcs.hanlp.dictionary.CoreDictionary.get(CoreDictionary.java:183) at com.hankcs.hanlp.dictionary.ns.PlaceDictionary.(PlaceDictionary.java:60) ... 23 more

yuchaozhou avatar May 04 '15 09:05 yuchaozhou

问题已经确认,新版本1.1.5不兼容旧版本的缓存。

  1. 词典由AhoCorasickDoubleArrayTrie降级为DoubleArrayTrie,内存占用减少一半
  2. 所以词典的缓存与旧版不兼容,请删除缓存或者下载data-for-1.1.5.zip

hankcs avatar May 04 '15 09:05 hankcs

是的,发出issue后,发现删除缓存问题解决了。hankcs加油完善,赞~

yuchaozhou avatar May 04 '15 10:05 yuchaozhou

感谢支持! 已经加入了一些防止缓存不兼容的安全措施。

hankcs avatar May 04 '15 10:05 hankcs