Search in sources :

Example 1 with FeatureFunction

use of com.hankcs.hanlp.model.crf.FeatureFunction 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)

Aggregations

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