亚洲国产欧美一区二区三区丁香婷,国产精品高潮呻吟久久av免费看 ,欧美无遮挡一区二区三区国产对白,日本一区二区免费不卡中文字幕

lucene得到分詞后的關(guān)鍵字

需要的時(shí)間也不同我的電腦上大概分詞需要800+ms分詞器工作流程:name?不同分詞器分法不同→消除停用詞()what)...

使用不同的分詞器科領(lǐng)摳像拍照軟件,最終的關(guān)鍵詞不同關(guān)鍵詞分詞器綠色版照片轉(zhuǎn)手繪軟件(SoftOrbits Sketch Drawer),所需的時(shí)間也不同

用中文分詞是個(gè)不錯(cuò)的選擇,但是對(duì)比時(shí)間關(guān)鍵詞分詞器綠色版devCad(CAD建模軟件),在我的電腦上分詞大約需要800+ms

標(biāo)記器工作流程:

輸入文字(你叫什么名字?)

→關(guān)鍵詞劃分(What's ; your ; name),不同的分詞器對(duì)不同的分詞方法不同

→刪除停用詞()

→形式恢復(fù)(什么 -> 什么)

→轉(zhuǎn)換為小寫(What -> what)

private long stime;
private long etime;
private Analyzer analyzer;
@Before
public void s(){
	stime = System.currentTimeMillis();
}
@After
public void e(){
	etime = System.currentTimeMillis();
	System.out.println("使用" + analyzer.getClass().getName() + "分詞, 耗時(shí)" + (etime - stime) + "ms");
}
@Test
public void test() throws Exception {
	//analyzer = new SimpleAnalyzer(Version.LUCENE_35);
	//analyzer = new StandardAnalyzer(Version.LUCENE_35);
	analyzer = new IKAnalyzer();
	analyze(analyzer, "hTTp://www.baidu.com/s?wd=Lucene中文分詞");
}
private void analyze(Analyzer analyzer, String text) throws Exception {
	TokenStream tokens = analyzer.reusableTokenStream("content", new StringReader(text));
	OffsetAttribute offsetAttr = tokens.getAttribute(OffsetAttribute.class);
	CharTermAttribute charTermAttr = tokens.getAttribute(CharTermAttribute.class);
	while (tokens.incrementToken()) {
		char[] charBuf = charTermAttr.buffer();
		String term = new String(charBuf, 0, offsetAttr.endOffset() - offsetAttr.startOffset());
		System.out.println(term + ", " + offsetAttr.startOffset() + ", " + offsetAttr.endOffset());
	}
	tokens.close();
	// while (ts.incrementToken()) {//過時(shí)
	// TermAttribute ta = ts.getAttribute(TermAttribute.class);
	// System.out.println(ta.term());
	// }
}

發(fā)表評(píng)論