All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mayabot.nlp.segment.plugins.pattern.PatternPlugin Maven / Gradle / Ivy

There is a newer version: 4.0.0
Show newest version
package com.mayabot.nlp.segment.plugins.pattern;

import com.mayabot.nlp.segment.pipeline.PipelineLexerBuilder;
import com.mayabot.nlp.segment.pipeline.PipelineLexerPlugin;

import java.util.regex.Pattern;

/**
 * 基于正则表达式的分词插件
 *
 * @author jimichan
 */
public class PatternPlugin implements PipelineLexerPlugin {

    private Pattern pattern;

    public static PatternPlugin of(Pattern pattern) {
        return new PatternPlugin(pattern);
    }

    public PatternPlugin(Pattern pattern) {
        this.pattern = pattern;
    }

    @Override
    public void install(PipelineLexerBuilder builder) {
        builder.addProcessor(new PatternWordpathProcessor(pattern));
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy