lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sean Dague <s...@dague.net>
Subject Sample SynonymAnalyzer vs. Lucene 2.2
Date Fri, 19 Oct 2007 12:42:18 GMT
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.
__________________________________________________________________

Mime
View raw message