Search in sources :

Example 1 with FeatureTemplate

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

the class TestCRF method testTestLoadTemplate.

public void testTestLoadTemplate() throws Exception {
    DataOutputStream out = new DataOutputStream(new FileOutputStream("data/test/out.bin"));
    FeatureTemplate featureTemplate = FeatureTemplate.create("U05:%x[-2,0]/%x[-1,0]/%x[0,0]");
    featureTemplate.save(out);
    featureTemplate = new FeatureTemplate();
    featureTemplate.load(ByteArray.createByteArray("data/test/out.bin"));
    System.out.println(featureTemplate);
}
Also used : FeatureTemplate(com.hankcs.hanlp.model.crf.FeatureTemplate)

Example 2 with FeatureTemplate

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

the class TestCRF method testTemplate.

public void testTemplate() throws Exception {
    FeatureTemplate featureTemplate = FeatureTemplate.create("U05:%x[-2,0]/%x[-1,0]/%x[0,0]");
    Table table = new Table();
    table.v = new String[][] { { "那", "S" }, { "音", "B" }, { "韵", "E" } };
    char[] parameter = featureTemplate.generateParameter(table, 0);
    System.out.println(parameter);
}
Also used : FeatureTemplate(com.hankcs.hanlp.model.crf.FeatureTemplate) Table(com.hankcs.hanlp.model.crf.Table)

Aggregations

FeatureTemplate (com.hankcs.hanlp.model.crf.FeatureTemplate)2 Table (com.hankcs.hanlp.model.crf.Table)1