Java源码示例:com.huaban.analysis.jieba.JiebaSegmenter.SegMode

示例1
@Override
public KeyValue<JiebaSegmenter, SegMode> build(Map<String, String> configurations) {
    String configuration = get(configurations, "mode", "search");
    SegMode mode;
    switch (configuration) {
    case "index":
        mode = SegMode.INDEX;
        break;
    case "search":
        mode = SegMode.SEARCH;
        break;
    default:
        throw new IllegalArgumentException();
    }

    JiebaSegmenter segmenter = new JiebaSegmenter();

    return new KeyValue<>(segmenter, mode);
}
 
示例2
public JiebaAdapter(Reader input, String segModeName, String userDictPath) {

		this.jiebaTagger = new JiebaSegmenter();

		if (null == segModeName) {
			segMode = SegMode.SEARCH;
		} else {
			segMode = SegMode.valueOf(segModeName);
		}
		if (null != userDictPath) {
			try{
				WordDictionary dictAdd = WordDictionary.getInstance();
				File file = new File(userDictPath);
				dictAdd.loadUserDict(file.toPath());
				System.out.println("load userDict: " + userDictPath + " succ!");
			} catch (Exception e) {
				e.printStackTrace();
				System.out.println("load userDict: " + userDictPath + " fail!");
			}
		} else {
			System.out.println("load userDict: " + userDictPath + " ??");
		}
	}
 
示例3
public JiebaTokenizerFactory(Map<String, String> configuration) {
    super(configuration);
    if (null == configuration.get("segMode")) {
        segMode = SegMode.SEARCH;
    } else {
        segMode = JiebaSegmenter.SegMode.valueOf(configuration.get("segMode"));
    }
}
 
示例4
@Override
protected NlpTokenizer<? extends NlpToken> getNlpTokenizer(Map<String, String> configurations) {
    KeyValue<JiebaSegmenter, SegMode> keyValue = build(configurations);
    JiebaSegmenter segmenter = keyValue.getKey();
    SegMode mode = keyValue.getValue();

    JiebaTokenizer tokenizer = new JiebaTokenizer(segmenter, mode);
    return tokenizer;
}
 
示例5
public JiebaAdapter(String segModeName) {


    System.out.println("init jieba adapter");
    if (null == segModeName) {
      segMode = SegMode.SEARCH;
    } else {
      segMode = SegMode.valueOf(segModeName);
    }
  }
 
示例6
public JiebaTokenizerFactory(Map<String, String> args) {
	super(args);
       if (null == args.get("segMode")) {
       	segMode = SegMode.SEARCH.name();
       } else {
       	segMode = args.get("segMode");
       }
	if (null == args.get("userDict")) {
		userDictPath = null;
	} else {
		userDictPath = args.get("userDict");
	}
}
 
示例7
public JiebaAdapter(Reader input, String segModeName) {

		this.jiebaTagger = new JiebaSegmenter();

		if (null == segModeName) {
			segMode = SegMode.SEARCH;
		} else {
			segMode = SegMode.valueOf(segModeName);
		}
	}
 
示例8
public JiebaTokenizerFactory(Map<String, String> args) {
	super(args);
       assureMatchVersion();
       if (null == args.get("segMode")) {
       	segMode = SegMode.SEARCH.name();
       } else {
       	segMode = args.get("segMode");
       }
}
 
示例9
public JiebaTokenizer(JiebaSegmenter segmenter, SegMode mode) {
    this.segmenter = segmenter;
    this.mode = mode;
}
 
示例10
@Override
protected Tokenizer getSegmenter() {
    JiebaTokenizer tokenizer = new JiebaTokenizer(SegMode.SEARCH);
    return tokenizer;
}
 
示例11
@Override
protected NlpTokenizer<? extends NlpToken> getTokenizer() {
    JiebaSegmenter segmenter = new JiebaSegmenter();
    SegMode mode = SegMode.SEARCH;
    return new JiebaTokenizer(segmenter, mode);
}
 
示例12
/**
 * 
 */
public JiebaAnalyzer() {
	this(SegMode.SEARCH.name());
}
 
示例13
/**
 * 
 */
public JiebaAnalyzer() {
	this(SegMode.SEARCH.name());
}