Coder Social home page Coder Social logo

Comments (11)

hankcs avatar hankcs commented on May 14, 2024

https://github.com/hankcs/HanLP/releases 最新的都会发布在这里。

from hanlp.

waiteryee127 avatar waiteryee127 commented on May 14, 2024

目前运行CRFModelTest时会报找不到CRFSegmentModel.txt的error。可能我没表述清楚,有没有可以下载CRFSegmentModel.txt这个模型的链接?

from hanlp.

hankcs avatar hankcs commented on May 14, 2024

代码库中好像没有CRFModelTest这个类,请给出完整路径。

CRFSegmentModel.txt是CRF++训练出来的文本模型,转成bin之后就删掉了。

from hanlp.

waiteryee127 avatar waiteryee127 commented on May 14, 2024

是没有这个类,只是想表达测试CRF模型这个意思,让你受干扰了,我把错误给你贴一下吧哈
八月 17, 2015 10:06:52 上午 com.hankcs.hanlp.model.CRFSegmentModel
严重: CRF分词模型加载 D:/JavaProjects/HanLP/data/model/segment/CRFSegmentModel.txt 失败,耗时 941 ms

from hanlp.

hankcs avatar hankcs commented on May 14, 2024

哦,明白了。

你想自己加载CRF分词模型,于是用了 new CRFSegmentModel 。但是在设计上CRFSegmentModel 是个静态包装类,默认加载data/model/segment/CRFSegmentModel.txt,如果存在data/model/segment/CRFSegmentModel.txt.bin则优先加载bin,否则加载txt,连txt都没有则终止加载。

正确的加载方式是

    String path = HanLP.Config.CRFSegmentModelPath + Predefine.BIN_EXT;
    CRFModel model = new CRFModel(new BinTrie<FeatureFunction>());
    model.load(ByteArray.createByteArray(path));

    Table table = new Table();
    String text = "人民生活进一步改善了";
    table.v = new String[text.length()][2];
    for (int i = 0; i < text.length(); i++)
    {
        table.v[i][0] = String.valueOf(text.charAt(i));
    }

    model.tag(table);
    System.out.println(table);

from hanlp.

waiteryee127 avatar waiteryee127 commented on May 14, 2024

哦,谢谢了。git上给的例子就是直接new CRFSegmentModel,我也没太仔细看哈。

from hanlp.

hankcs avatar hankcs commented on May 14, 2024

不客气,不过至少在当前版本,没有创建过CRFSegmentModel的实例。

from hanlp.

waiteryee127 avatar waiteryee127 commented on May 14, 2024

我用v1.2.4发布的jar包,用你给的加载方式还是会有错误。
at com.hankcs.hanlp.model.crf.CRFModel.tag(CRFModel.java:185)
at com.hankcs.demo.DemoCRFSegment.main(DemoCRFSegment.java:75)

75行是model.tag(table);
同时也没看到data/model/segment/CRFSegmentModel.txt.bin这个文件。

from hanlp.

hankcs avatar hankcs commented on May 14, 2024

请自己下载data,解压配置路径。

from hanlp.

shaohualuan avatar shaohualuan commented on May 14, 2024

请问这个警告: 读取data/model/segment/CRFSegmentModel.txt.bin时发生异常java.io.FileNotFoundException: data\model\segment\CRFSegmentModel.txt.bin (系统找不到指定的路径。)这个模型是要自己去跑,还是单独要在vs上跑完集成过来

from hanlp.

hankcs avatar hankcs commented on May 14, 2024

已废弃CRFSegment,请使用功能更丰富、设计更优雅的CRFLexicalAnalyzer

from hanlp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.