lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Allen Atamer" <aata...@casebank.com>
Subject implementing a TokenFilter for aliases
Date Thu, 04 Dec 2003 22:00:42 GMT
The FAQ describes implementing a TokenFilter for applying aliases. I have a
trouble accomplishing this.
 
This is the code that I have so far for the next Method within AliasFilter.
After reading some posts, I also got the idea to call
setPositionIncrement(). Neither way works, because when I search for the
alias, no search results come back.
 
Thank you for your help,
 
Allen Atamer
 
----
 
  public Token next() throws java.io.IOException {
    Token token = tokenStream.next();
 
    if (aliasMap == null || token == null) {
      return token;
    }
 
    TermData t = (TermData)aliasMap.get(token.termText());
 
    if (t == null) {
      return token;
    }
 
    String tokenText = AliasManager.replaceIgnoreCase(
        token.termText(), t.getTerm(), t.getTeach());
 
    int increment = tokenText.length() - token.termText().length();
    if (increment > 0) {
      token.setPositionIncrement(increment);
    }
 
    return new Token(tokenText, token.startOffset(), token.endOffset());
  }
 
 
 
 
 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message