• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Dictionary类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SafeModeAction类代码示例发布时间:2022-05-23
下一篇:
Java BeanPropertyWriter类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap