You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Sean Dague <se...@dague.net> on 2007/10/19 14:42:18 UTC
Sample SynonymAnalyzer vs. Lucene 2.2
I've noticed that the sample code to do the SynonymAnalyzer from the
book Lucene in Action doesn't work right on Lucene 2.2. In my sample
application I am using categorizing food names into food categories
using the Synonym patern.
Using the excerpted:
private void addAliasesToStack(Token token) throws IOException {
String[] synonyms = engine.getSynonyms(token.termText());
if (synonyms == null) return;
for (int i = 0; i < synonyms.length; i++) {
Token synToken = new Token(synonyms[i],
token.startOffset(),
token.endOffset(),
TOKEN_TYPE_SYNONYM);
synToken.setPositionIncrement(0);
synonymStack.push(synToken);
}
}
Ends up only indexing the synonym, but not the base word itself. If I
comment out the 'synToken.setPositionIncrement(0)' line, it works, but
now that throws off the token positions. This probably doesn't matter,
but I'm curious what the new prefered approach is here?
Thanks in advance,
-Sean
--
__________________________________________________________________
Sean Dague Mid-Hudson Valley
sean at dague dot net Linux Users Group
http://dague.net http://mhvlug.org
There is no silver bullet. Plus, werewolves make better neighbors
than zombies, and they tend to keep the vampire population down.
__________________________________________________________________
Re: Sample SynonymAnalyzer vs. Lucene 2.2
Posted by Daniel Naber <lu...@danielnaber.de>.
On Friday 19 October 2007 14:42, Sean Dague wrote:
> Ends up only indexing the synonym, but not the base word itself.
I cannot reproduce the problem, i.e. I see both the original term and its
synonyms in the index. Maybe you can post the analyzer that uses this
filter or a test case to reproduce the problem?
Regards
Daniel
--
http://www.danielnaber.de
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org