Holen@Blog

Holen Bolg on Donews.net

  DonewsBlog  |  Donews首页  |  Donews社区  |  Donews邮箱  |  我的首页  |  联系作者  |  聚合   |  登录
  216篇文章 :: 0篇收藏:: 353篇评论:: 6个Trackbacks

公告

Free Counters

文章

收藏

相册

我的原创文章

存档


正在读取评论……


Sure. An analyzer is basically a factory object that creates a TokenStream object used to tokenized the text. A typical analyzer implementation creates the TokenStream by creating a standard tokenizer and combining it with a series of filters, each perform a different processing of the token stream.

Here is a sample customized analyzer contributed by Joanne Proton:

public class MyAnalyzer extends Analyzer { /* * An array containing some common words that * are not usually useful for searching. */ private static final String[] STOP_WORDS = { "a" , "and" , "are" , "as" , "at" , "be" , "but" , "by" , "for" , "if" , "in" , "into" , "is" , "it" , "no" , "not" , "of" , "on" , "or" , "s" , "such" , "t" , "that" , "the" , "their" , "then" , "there" , "these" , "they" , "this" , "to" , "was" , "will" , "with" }; /* * Stop table */ final static private Hashtable stopTable = StopFilter.makeStopTable(STOP_WORDS); /* * Create a token stream for this analyzer. */ public final TokenStream tokenStream(final Reader reader) { TokenStream result = new StandardTokenizer(reader); result = new StandardFilter(result); result = new LowerCaseFilter(result); result = new StopFilter(result, stopTable); result = new PorterStemFilter(result); return result; } 


Trackback: http://tb.donews.net/TrackBack.aspx?PostId=123043


[点击此处收藏本文]  发表于2004年10月08日 10:57 AM




正在读取评论……

发表评论

大名:
网址:
验证码
评论