Package com.chenlb.mmseg4j

Examples of com.chenlb.mmseg4j.Dictionary


      System.out.println("\tPerformance <txt path> - is a directory that contain *.txt");
      return;
    }
    String mode = System.getProperty("mode", "complex");
    Seg seg = null;
    Dictionary dic = Dictionary.getInstance();
    if("simple".equals(mode)) {
      seg = new SimpleSeg(dic);
    } else {
      seg = new ComplexSeg(dic);
    }
View Full Code Here


import com.chenlb.mmseg4j.Dictionary;

public class Utils {

  public static Dictionary getDict(String dicPath, ResourceLoader loader) {
    Dictionary dic = null;
    if(dicPath != null) {
      File f = new File(dicPath);
      if(!f.isAbsolute() && loader instanceof SolrResourceLoader) {  //相对目录
        SolrResourceLoader srl = (SolrResourceLoader) loader;
        dicPath = srl.getInstanceDir()+dicPath;
View Full Code Here

import com.chenlb.mmseg4j.Dictionary;

public class Utils {

  public static Dictionary getDict(String dicPath, ResourceLoader loader) {
    Dictionary dic = null;
    if(dicPath != null) {
      File f = new File(dicPath);
      if(!f.isAbsolute() && loader instanceof SolrResourceLoader) {  //相对目录
        SolrResourceLoader srl = (SolrResourceLoader) loader;
        dicPath = srl.getInstanceDir()+dicPath;
View Full Code Here

  public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
    rsp.setHttpCaching(false);
    final SolrParams solrParams = req.getParams();

    String dicPath = solrParams.get("dicPath");
    Dictionary dict = Utils.getDict(dicPath, loader);

    NamedList<Object> result = new NamedList<Object>();
    result.add("dicPath", dict.getDicPath().toURI());

    boolean check = solrParams.getBool("check", false)//仅仅用于检测词库是否有变化
    //用于尝试加载词库,有此参数, check 参数可以省略。
    boolean reload = solrParams.getBool("reload", false)

    check |= reload;

    boolean changed = false;
    boolean reloaded = false;
    if(check) {
      changed = dict.wordsFileIsChange();
      result.add("changed", changed);
    }
    if(changed && reload) {
      reloaded = dict.reload();
      result.add("reloaded", reloaded);
    }
    rsp.add("result", result);
  }
View Full Code Here

TOP

Related Classes of com.chenlb.mmseg4j.Dictionary

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.