lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Miller <markrmil...@gmail.com>
Subject Re: Quotes dependent StopWords removal
Date Wed, 16 Aug 2006 01:09:44 GMT
My last answer was terrible. QueryParser will not sent any parenthesis 
into the analyzer. How about this:

Below are lines about 965-992 of QueryParser.java. Change 
getFieldQuery(field, term.image.substring(1, term.image.length()-1), s) 
(line 992) to call an identical function to the one called except have 
this function use an analyzer that does not remove stop words. Case 
QUOTED occurs when a QUOTED token is eaten. getFieldQuery puts that 
token (or tokens, possibly at the same position) through an analyzer and 
returns a Query object. You want that analyzer that is used to not strip 
stop words if the token type is QUOTED. Sounds reasonable to me.

Now replacing the entire method to just change the analyzer is very 
brute force but maybe it will spark an idea to something more elegant. 
Same "bear in mind this might be BS" applies to this answer.

- Mark

line 965 of QueryParser.java
    case QUOTED:
      term = jj_consume_token(QUOTED);
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case FUZZY_SLOP:
        fuzzySlop = jj_consume_token(FUZZY_SLOP);
        break;
      default:
        jj_la1[19] = jj_gen;
        ;
      }
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case CARAT:
        jj_consume_token(CARAT);
        boost = jj_consume_token(NUMBER);
        break;
      default:
        jj_la1[20] = jj_gen;
        ;
      }
         int s = phraseSlop;

         if (fuzzySlop != null) {
           try {
             s = Float.valueOf(fuzzySlop.image.substring(1)).intValue();
           }
           catch (Exception ignored) { }
         }
         q = getFieldQuery(field, term.image.substring(1, 
term.image.length()-1), s);

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message