本文整理汇总了Java中com.chenlb.mmseg4j.Dictionary类的典型用法代码示例。如果您正苦于以下问题:Java Dictionary类的具体用法?Java Dictionary怎么用?Java Dictionary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Dictionary类属于com.chenlb.mmseg4j包,在下文中一共展示了Dictionary类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getDict
import com.chenlb.mmseg4j.Dictionary; //导入依赖的package包/类
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;
f = new File(dicPath);
}
dic = Dictionary.getInstance(f);
} else {
dic = Dictionary.getInstance();
}
return dic;
}
开发者ID:wanghaile,项目名称:mmseg4j,代码行数:17,代码来源:Utils.java
示例2: getDict
import com.chenlb.mmseg4j.Dictionary; //导入依赖的package包/类
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.getInstancePath().resolve(dicPath).toString();
f = new File(dicPath);
}
dic = Dictionary.getInstance(f);
} else {
dic = Dictionary.getInstance();
}
return dic;
}
开发者ID:chenlb,项目名称:mmseg4j-solr,代码行数:17,代码来源:Utils.java
示例3: testStandard
import com.chenlb.mmseg4j.Dictionary; //导入依赖的package包/类
@Test
public void testStandard() throws IOException {
FileInputStream fis = new FileInputStream("src/test/resources/text-sentence.txt");
Dictionary.load(fis, new FileLoading() {
StandardAnalyzer sa = new StandardAnalyzer();
@Override
public void row(String line, int n) {
//System.out.println("n=" + n + " -> " + toWords(line, sa));
// 保证标准的可运行
toWords(line, sa);
}
});
}
开发者ID:chenlb,项目名称:mmseg4j-solr,代码行数:19,代码来源:AnalyzerTest.java
示例4: assertTokenizerFactory
import com.chenlb.mmseg4j.Dictionary; //导入依赖的package包/类
private void assertTokenizerFactory(final String fieldName, final Seg seg) throws IOException {
logger.info("assert TokenizerFactory field type={}", fieldName);
FileInputStream fis = new FileInputStream("src/test/resources/text-sentence.txt");
try {
Dictionary.load(fis, new FileLoading() {
@Override
public void row(String line, int n) {
List<String> mwords = AnalyzerTest.toMMsegWords(line, seg);
assertU(adoc("id", String.valueOf(n), fieldName, line));
assertU(commit());
logger.debug("words = {}", mwords);
for (String word : mwords) {
assertQ(req("q", "id:" + String.valueOf(n) + " AND " + fieldName + ":" + word),
"//*[@numFound='1']",
"//result/doc[1]/int[@name='id'][.='" + String.valueOf(n) + "']");
}
}
});
} finally {
fis.close();
}
}
开发者ID:chenlb,项目名称:mmseg4j-solr,代码行数:26,代码来源:MMSegTokenizerFactoryTest.java
示例5: handleRequestBody
import com.chenlb.mmseg4j.Dictionary; //导入依赖的package包/类
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);
}
开发者ID:wanghaile,项目名称:mmseg4j,代码行数:29,代码来源:MMseg4jHandler.java
示例6: testSimple
import com.chenlb.mmseg4j.Dictionary; //导入依赖的package包/类
@Test
public void testSimple() throws FileNotFoundException, IOException {
FileInputStream fis = new FileInputStream("src/test/resources/text-sentence.txt");
try {
Dictionary.load(fis, new AssertFileLoading(new SimpleSeg(dic), new SimpleAnalyzer()));
} finally {
fis.close();
}
}
开发者ID:chenlb,项目名称:mmseg4j-solr,代码行数:10,代码来源:AnalyzerTest.java
示例7: testComplex
import com.chenlb.mmseg4j.Dictionary; //导入依赖的package包/类
@Test
public void testComplex() throws IOException {
FileInputStream fis = new FileInputStream("src/test/resources/text-sentence.txt");
try {
Dictionary.load(fis, new AssertFileLoading(new ComplexSeg(dic), new ComplexAnalyzer()));
} finally {
fis.close();
}
}
开发者ID:chenlb,项目名称:mmseg4j-solr,代码行数:10,代码来源:AnalyzerTest.java
示例8: testMaxWord
import com.chenlb.mmseg4j.Dictionary; //导入依赖的package包/类
@Test
public void testMaxWord() throws IOException {
FileInputStream fis = new FileInputStream("src/test/resources/text-sentence.txt");
try {
Dictionary.load(fis, new AssertFileLoading(new MaxWordSeg(dic), new MaxWordAnalyzer()));
} finally {
fis.close();
}
}
开发者ID:chenlb,项目名称:mmseg4j-solr,代码行数:10,代码来源:AnalyzerTest.java
示例9: getDictionaryByFieldType
import com.chenlb.mmseg4j.Dictionary; //导入依赖的package包/类
private Dictionary getDictionaryByFieldType(String fieldTypeName) {
FieldType ft = h.getCore().getLatestSchema().getFieldTypeByName(fieldTypeName);
Analyzer a = ft.getIndexAnalyzer();
Assert.assertEquals(a.getClass(), TokenizerChain.class);
TokenizerChain tc = (TokenizerChain) a;
TokenizerFactory tf = tc.getTokenizerFactory();
Assert.assertEquals(tf.getClass(), MMSegTokenizerFactory.class);
MMSegTokenizerFactory mtf = (MMSegTokenizerFactory) tf;
Assert.assertNotNull(mtf.dic);
return mtf.dic;
}
开发者ID:chenlb,项目名称:mmseg4j-solr,代码行数:15,代码来源:MMSegTokenizerFactoryTest.java
示例10: SimpleAnalyzer
import com.chenlb.mmseg4j.Dictionary; //导入依赖的package包/类
public SimpleAnalyzer(Dictionary dic) {
super(dic);
}
开发者ID:wanghaile,项目名称:mmseg4j,代码行数:4,代码来源:SimpleAnalyzer.java
示例11: MMSegAnalyzer
import com.chenlb.mmseg4j.Dictionary; //导入依赖的package包/类
/**
* @see Dictionary#getInstance()
*/
public MMSegAnalyzer() {
dic = Dictionary.getInstance();
}
开发者ID:wanghaile,项目名称:mmseg4j,代码行数:7,代码来源:MMSegAnalyzer.java
示例12: getDict
import com.chenlb.mmseg4j.Dictionary; //导入依赖的package包/类
public Dictionary getDict() {
return dic;
}
开发者ID:wanghaile,项目名称:mmseg4j,代码行数:4,代码来源:MMSegAnalyzer.java
示例13: ComplexAnalyzer
import com.chenlb.mmseg4j.Dictionary; //导入依赖的package包/类
public ComplexAnalyzer(Dictionary dic) {
super(dic);
}
开发者ID:wanghaile,项目名称:mmseg4j,代码行数:4,代码来源:ComplexAnalyzer.java
示例14: MaxWordAnalyzer
import com.chenlb.mmseg4j.Dictionary; //导入依赖的package包/类
public MaxWordAnalyzer(Dictionary dic) {
super(dic);
}
开发者ID:wanghaile,项目名称:mmseg4j,代码行数:4,代码来源:MaxWordAnalyzer.java
示例15: Complex
import com.chenlb.mmseg4j.Dictionary; //导入依赖的package包/类
public Complex() {
dic = Dictionary.getInstance();
}
开发者ID:wanghaile,项目名称:mmseg4j,代码行数:4,代码来源:Complex.java
示例16: MMSegAnalyzer
import com.chenlb.mmseg4j.Dictionary; //导入依赖的package包/类
public MMSegAnalyzer() {
dic = Dictionary.getInstance();
}
开发者ID:Smalinuxer,项目名称:Rearchor,代码行数:4,代码来源:MMSegAnalyzer.java
示例17: beforeClass
import com.chenlb.mmseg4j.Dictionary; //导入依赖的package包/类
@BeforeClass
public static void beforeClass() {
dic = Dictionary.getInstance();
}
开发者ID:chenlb,项目名称:mmseg4j-solr,代码行数:5,代码来源:AnalyzerTest.java
注:本文中的com.chenlb.mmseg4j.Dictionary类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论