Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DemoNShortSegment数组越界异常 #870

Closed
godfatherzzx opened this issue Jun 26, 2018 · 1 comment
Closed

DemoNShortSegment数组越界异常 #870

godfatherzzx opened this issue Jun 26, 2018 · 1 comment
Labels

Comments

@godfatherzzx
Copy link

注意事项

请确认下列注意事项:

  • 我已仔细阅读下列文档,都没有找到答案:
  • 我已经通过Googleissue区检索功能搜索了我的问题,也没有找到答案。
  • 我明白开源社区是出于兴趣爱好聚集起来的自由社区,不承担任何责任或义务。我会礼貌发言,向每一个帮助我的人表示感谢。
  • [x ] 我在此括号内输入x打钩,代表上述事项确认完毕。

版本号

当前最新版本号是:portable-1.6.5
我使用的版本是:portable-1.6.5

我的问题

直接checkout工程,运行test/java/com/hankcs/demo/DemoNShortSegment时,报ArrayIndexOutOfBoundsException。

复现问题

步骤

  1. 首先……
  2. 然后……
  3. 接着……

触发代码

  public class DemoNShortSegment
{
    public static void main(String[] args)
    {
        Segment nShortSegment = new NShortSegment().enableCustomDictionary(false).enablePlaceRecognize(true).enableOrganizationRecognize(true);
        Segment shortestSegment = new ViterbiSegment().enableCustomDictionary(false).enablePlaceRecognize(true).enableOrganizationRecognize(true);
        String[] testCase = new String[]{
                "今天,刘志军案的关键人物,山西女商人丁书苗在市二中院出庭受审。",
                "江西省监狱管理局与中国太平洋财产保险股份有限公司南昌中心支公司保险合同纠纷案",
                "新北商贸有限公司",
        };
        for (String sentence : testCase)
        {
            System.out.println("N-最短分词:" + nShortSegment.seg(sentence) + "\n最短路分词:" + shortestSegment.seg(sentence));
        }
    }
}

期望输出

期望输出

实际输出

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 40
	at com.hankcs.hanlp.seg.common.WordNet.get(WordNet.java:216)
	at com.hankcs.hanlp.seg.common.WordNet.insert(WordNet.java:168)
	at com.hankcs.hanlp.dictionary.nt.OrganizationDictionary$1.hit(OrganizationDictionary.java:3779)
	at com.hankcs.hanlp.dictionary.nt.OrganizationDictionary$1.hit(OrganizationDictionary.java:3756)
	at com.hankcs.hanlp.collection.AhoCorasick.AhoCorasickDoubleArrayTrie.parseText(AhoCorasickDoubleArrayTrie.java:115)
	at com.hankcs.hanlp.dictionary.nt.OrganizationDictionary.parsePattern(OrganizationDictionary.java:3755)
	at com.hankcs.hanlp.recognition.nt.OrganizationRecognition.recognition(OrganizationRecognition.java:71)
	at com.hankcs.hanlp.seg.NShort.NShortSegment.segSentence(NShortSegment.java:79)
	at com.hankcs.hanlp.seg.Segment.seg(Segment.java:557)
	at com.hankcs.demo.DemoNShortSegment.main(DemoNShortSegment.java:36)

其他信息

@hankcs
Copy link
Owner

hankcs commented Jun 26, 2018

感谢测试pre-release版,已经修复,请参考上面的commit。
如果还有问题,欢迎重开issue。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants