How do I write my own Analyzer?
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Otis_Gospodnetic
Posted On:   Monday, September 30, 2002 08:56 PM

Here is an example: public class MyAnalyzer extends Analyzer { private Analyzer standard = new StandardAnalyzer(); public TokenStream tokenStream(String field, final Reader reader) { if ("element".equals(field)) // do not tokenize { return new CharTokenizer(reader) { protected boolean isTokenChar(char c) { return true; } }; } } else { // use standard analyzer return standard.tokenStream(field, reader); } }    More>>

Here is an example:

			
public class MyAnalyzer extends Analyzer
{
private Analyzer standard = new StandardAnalyzer();

public TokenStream tokenStream(String field, final Reader reader)
{
if ("element".equals(field)) // do not tokenize
{
return new CharTokenizer(reader)
{
protected boolean isTokenChar(char c)
{
return true;
}
};
}
}
else
{
// use standard analyzer
return standard.tokenStream(field, reader);
}
}
   <<Less
About | Sitemap | Contact