List Info

Thread: Sample SynonymAnalyzer vs. Lucene 2.2




Sample SynonymAnalyzer vs. Lucene 2.2
user name
2007-10-19 07:42:18
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
country flaguser name
Germany
2007-10-19 14:37:26
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-unsubscribelucene.apache.org
For additional commands, e-mail: java-user-helplucene.apache.org


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )