Search in sources :

Example 1 with CRFModel

use of com.hankcs.hanlp.model.crf.CRFModel in project HanLP by hankcs.

the class TestCRF method testLoadModelWithBiGramFeature.

public void testLoadModelWithBiGramFeature() throws Exception {
    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);
}
Also used : CRFModel(com.hankcs.hanlp.model.crf.CRFModel) Table(com.hankcs.hanlp.model.crf.Table) FeatureFunction(com.hankcs.hanlp.model.crf.FeatureFunction)

Example 2 with CRFModel

use of com.hankcs.hanlp.model.crf.CRFModel in project HanLP by hankcs.

the class TestCRF method testLoadFromTxt.

public void testLoadFromTxt() throws Exception {
    CRFModel model = CRFModel.loadTxt("D:\\Tools\\CRF++-0.58\\example\\seg_cn\\model.txt");
    Table table = new Table();
    table.v = new String[][] { { "商", "?" }, { "品", "?" }, { "和", "?" }, { "服", "?" }, { "务", "?" } };
    model.tag(table);
    System.out.println(table);
}
Also used : CRFModel(com.hankcs.hanlp.model.crf.CRFModel) Table(com.hankcs.hanlp.model.crf.Table)

Example 3 with CRFModel

use of com.hankcs.hanlp.model.crf.CRFModel in project HanLP by hankcs.

the class TestCRF method testLoadModelWhichHasNoB.

public void testLoadModelWhichHasNoB() throws Exception {
    CRFModel model = CRFModel.loadTxt("D:\\Tools\\CRF++-0.58\\example\\dependency\\model.txt");
    System.out.println(model);
}
Also used : CRFModel(com.hankcs.hanlp.model.crf.CRFModel)

Aggregations

CRFModel (com.hankcs.hanlp.model.crf.CRFModel)3 Table (com.hankcs.hanlp.model.crf.Table)2 FeatureFunction (com.hankcs.hanlp.model.crf.FeatureFunction)1