Skip to content

未进行修改, 自定义词典缓存失败 #1025

@inhzus

Description

@inhzus

注意事项

请确认下列注意事项:

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

版本号

使用python3.7.1 版本, 直接pip 安装得到
Windows 10 家庭中文版1803 17134.376
当前最新版本号是:1.7.0
我使用的版本是:1.7.0

我的问题

在我使用pip 安装后, 在命令行运行hanlp segment 下载过jar和data后, 输入测试任意用句, 会出现报错信息.

复现问题

在我清空以前的hanlp文件后, 重新pip 安装, 没有对data 中的任何数据修改, 直接使用hanlp segment即出现问题.

触发代码

$ hanlp segment
测试用句

实际输出

十一月 17, 2018 3:09:57 下午 com.hankcs.hanlp.dictionary.CustomDictionary loadDat
警告: 读取失败,问题发生在java.lang.ArrayIndexOutOfBoundsException: 7
        at com.hankcs.hanlp.utility.ByteUtil.bytesHighFirstToInt(ByteUtil.java:239)
        at com.hankcs.hanlp.corpus.io.ByteArray.nextInt(ByteArray.java:68)
        at com.hankcs.hanlp.dictionary.CustomDictionary.loadDat(CustomDictionary.java:325)
        at com.hankcs.hanlp.dictionary.CustomDictionary.loadMainDictionary(CustomDictionary.java:64)
        at com.hankcs.hanlp.dictionary.CustomDictionary.<clinit>(CustomDictionary.java:51)
        at com.hankcs.hanlp.seg.Segment.combineByCustomDictionary(Segment.java:203)
        at com.hankcs.hanlp.seg.Viterbi.ViterbiSegment.segSentence(ViterbiSegment.java:57)
        at com.hankcs.hanlp.seg.Segment.seg(Segment.java:557)

十一月 17, 2018 3:09:57 下午 com.hankcs.hanlp.dictionary.CustomDictionary load
严重: 自定义词典c:/program读取错误!java.io.FileNotFoundException: c:\program (系统找不到指定的文件。)
十一月 17, 2018 3:09:57 下午 com.hankcs.hanlp.dictionary.CustomDictionary loadMainDictionary
警告: 失败:c:/program
十一月 17, 2018 3:09:57 下午 com.hankcs.hanlp.dictionary.CustomDictionary load
严重: 自定义词典c:/program读取错误!java.io.FileNotFoundException: c:\program (系统找不到指定的文件。)
十一月 17, 2018 3:09:57 下午 com.hankcs.hanlp.dictionary.CustomDictionary loadMainDictionary
警告: 失败:c:/program
十一月 17, 2018 3:09:57 下午 com.hankcs.hanlp.dictionary.CustomDictionary load
严重: 自定义词典c:/program读取错误!java.io.FileNotFoundException: c:\program (系统找不到指定的文件。)
十一月 17, 2018 3:09:57 下午 com.hankcs.hanlp.dictionary.CustomDictionary loadMainDictionary
警告: 失败:c:/program
十一月 17, 2018 3:09:57 下午 com.hankcs.hanlp.dictionary.CustomDictionary load
严重: 自定义词典c:/program读取错误!java.io.FileNotFoundException: c:\program (系统找不到指定的文件。)
十一月 17, 2018 3:09:57 下午 com.hankcs.hanlp.dictionary.CustomDictionary loadMainDictionary
警告: 失败:c:/program
十一月 17, 2018 3:09:57 下午 com.hankcs.hanlp.dictionary.CustomDictionary load
严重: 自定义词典c:/program读取错误!java.io.FileNotFoundException: c:\program (系统找不到指定的文件。)
十一月 17, 2018 3:09:57 下午 com.hankcs.hanlp.dictionary.CustomDictionary loadMainDictionary
警告: 失败:c:/program
十一月 17, 2018 3:09:57 下午 com.hankcs.hanlp.dictionary.CustomDictionary load
严重: 自定义词典c:/program读取错误!java.io.FileNotFoundException: c:\program (系统找不到指定的文件。)
十一月 17, 2018 3:09:57 下午 com.hankcs.hanlp.dictionary.CustomDictionary loadMainDictionary
警告: 失败:c:/program
十一月 17, 2018 3:09:57 下午 com.hankcs.hanlp.dictionary.CustomDictionary load
严重: 自定义词典c:/program读取错误!java.io.FileNotFoundException: c:\program (系统找不到指定的文件。)
十一月 17, 2018 3:09:57 下午 com.hankcs.hanlp.dictionary.CustomDictionary loadMainDictionary
警告: 失败:c:/program
十一月 17, 2018 3:09:57 下午 com.hankcs.hanlp.dictionary.CustomDictionary loadMainDictionary
警告: 没有加载到任何词条
十一月 17, 2018 3:09:57 下午 com.hankcs.hanlp.dictionary.CustomDictionary loadMainDictionary
警告: 自定义词典c:/program files/python37/lib/site-packages/pyhanlp/static/data/dictionary/custom/CustomDictionary.txt缓存失败!
java.lang.NullPointerException
        at com.hankcs.hanlp.dictionary.CustomDictionary.loadMainDictionary(CustomDictionary.java:116)
        at com.hankcs.hanlp.dictionary.CustomDictionary.<clinit>(CustomDictionary.java:51)
        at com.hankcs.hanlp.seg.Segment.combineByCustomDictionary(Segment.java:203)
        at com.hankcs.hanlp.seg.Viterbi.ViterbiSegment.segSentence(ViterbiSegment.java:57)
        at com.hankcs.hanlp.seg.Segment.seg(Segment.java:557)

测试/vn 用/p 句/q

谢谢您的解答!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions