Mynlp的分词插件功能实现

2020-08-26  本文已影响0人  菠萝炒鸡蛋

代码:

/**
 * 字典插件
 */
public class PipelinePlugin {
    public static void main(String[] args) {
        //自定义词典
        MemCustomDictionary dictionary = new MemCustomDictionary();
        dictionary.addWord("逛吃");
        dictionary.rebuild();

        FluentLexerBuilder builder = Lexers.coreBuilder()
                .withPos()
                .withPersonName();

        //配置插件
        builder.with(new CustomDictionaryPlugin((dictionary)));

        Lexer lexer = builder.build();
        System.out.println(lexer.scan("逛吃行动小组成立"));
    }
}

上一篇下一篇

猜你喜欢

热点阅读