本文整理汇总了Java中org.wltea.analyzer.dic.Dictionary.initial方法的典型用法代码示例。如果您正苦于以下问题:Java Dictionary.initial方法的具体用法?Java Dictionary.initial怎么用?Java Dictionary.initial使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.wltea.analyzer.dic.Dictionary
的用法示例。
在下文中一共展示了Dictionary.initial方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIKAnalyzerResult
import org.wltea.analyzer.dic.Dictionary; //导入方法依赖的package包/类
public static List<String> getIKAnalyzerResult(String originTxt, boolean useSmart, Collection<String> words)throws Exception{
if(originTxt == null || originTxt.trim().equals("")){
return null;
}
//如下代码为动态增加新词的办法,可以完善成动态加载的接口
if(null != words && words.size() != 0){
Configuration cfg = DefaultConfig.getInstance();
Dictionary dic = Dictionary.initial(cfg);
dic = Dictionary.getSingleton();
dic.addWords(words);
}
InputStream in = new ByteArrayInputStream(originTxt.getBytes());
IKSegmenter ik = new IKSegmenter(new InputStreamReader(in), useSmart);
List<String> result = new ArrayList<String>();
Lexeme t = null;
while( (t=ik.next()) != null){
result.add(t.getLexemeText());
}
return result;
}
示例2: init
import org.wltea.analyzer.dic.Dictionary; //导入方法依赖的package包/类
/**
* 初始化
*/
private void init(){
//初始化词典单例
Dictionary.initial(this.cfg);
//初始化分词上下文
this.context = new AnalyzeContext(this.cfg);
//加载子分词器
this.segmenters = this.loadSegmenters();
//加载歧义裁决器
this.arbitrator = new IKArbitrator();
}
示例3: Configuration
import org.wltea.analyzer.dic.Dictionary; //导入方法依赖的package包/类
@Inject
public Configuration(Environment env,Settings settings) {
this.environment = env;
this.settings=settings;
this.useSmart = settings.get("use_smart", "false").equals("true");
this.enableLowercase = settings.get("enable_lowercase", "true").equals("true");
this.enableRemoteDict = settings.get("enable_remote_dict", "true").equals("true");
Dictionary.initial(this);
}