Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Lucene: Java-User

singular and plural search

 

 

Lucene java-user RSS feed   Index | Next | Previous | View Threaded


m.harig at gmail

Oct 21, 2009, 4:22 AM

Post #1 of 5 (1039 views)
Permalink
singular and plural search

hello all

i've a doubt in plural & singular word searching , i've got code
snippet from nabble forum ,

private static Analyzer createEnglishAnalyzer() {
return new Analyzer() {
public TokenStream tokenStream(String fieldName, Reader reader)
{
TokenStream result = new StandardTokenizer(reader);
result = new StandardFilter(result);
result = new LowerCaseFilter(result);
result = new StopFilter(result,
StandardAnalyzer.STOP_WORDS);
result = new SnowballFilter(result, "English");
return result;
}
};
}

to do my above , but when i search for a keyword "loans" , this code turns
my keyword to "loan" and gives me the results for "loan" keyword , but when
i search for "loan" it should return the results for "loans" keyword.

please anyone suggest me.
--
View this message in context: http://www.nabble.com/singular-and-plural-search-tp25990682p25990682.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene


erickerickson at gmail

Oct 21, 2009, 5:40 AM

Post #2 of 5 (991 views)
Permalink
Re: singular and plural search [In reply to]

A little more information would help here.1> Are you using the same analyzer
at both index and query time?
2> Assuming <1> is "yes", did you re-index your data after you created this
analyzer?
3> What are the results of query.toString()? Looking at that might help you
pinpoint what's going on.
4> Have you examined your index using Luke to see if it has what you *think*
it should?
5> If all of the above doesn't do you any good, I've usually found that
writing a small, self-contained test case to illustrate the problem is a
great help. Usually, during the course of writing the test case I find the
problem. And it's usually in my code <G>. And if it's *not* in my code, a
test case provides the Lucene folks with something to work with.

The analyzer itself looks like it should do what you want on a cursory
inspection.....

Best
Erick

On Wed, Oct 21, 2009 at 7:22 AM, m.harig <m.harig [at] gmail> wrote:

>
> hello all
>
> i've a doubt in plural & singular word searching , i've got code
> snippet from nabble forum ,
>
> private static Analyzer createEnglishAnalyzer() {
> return new Analyzer() {
> public TokenStream tokenStream(String fieldName, Reader reader)
> {
> TokenStream result = new StandardTokenizer(reader);
> result = new StandardFilter(result);
> result = new LowerCaseFilter(result);
> result = new StopFilter(result,
> StandardAnalyzer.STOP_WORDS);
> result = new SnowballFilter(result, "English");
> return result;
> }
> };
> }
>
> to do my above , but when i search for a keyword "loans" , this code turns
> my keyword to "loan" and gives me the results for "loan" keyword , but when
> i search for "loan" it should return the results for "loans" keyword.
>
> please anyone suggest me.
> --
> View this message in context:
> http://www.nabble.com/singular-and-plural-search-tp25990682p25990682.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
> For additional commands, e-mail: java-user-help [at] lucene
>
>


m.harig at gmail

Oct 21, 2009, 6:06 AM

Post #3 of 5 (1001 views)
Permalink
Re: singular and plural search [In reply to]

thanks erick ,

A little more information would help here.1> Are you using the same analyzer
at both index and query time?

no . sorry , am using StandardAnalyzer at the index time , during querying
am using the code snippet found from nabble.

2> Assuming <1> is "yes", did you re-index your data after you created this
analyzer?

no.

3> What are the results of query.toString()? Looking at that might help you
pinpoint what's going on.

am getting singular word for all field.

4> Have you examined your index using Luke to see if it has what you *think*
it should?

yes , i did it , it also returns the same

5> If all of the above doesn't do you any good, I've usually found that
writing a small, self-contained test case to illustrate the problem is a
great help. Usually, during the course of writing the test case I find the
problem. And it's usually in my code <G>. And if it's *not* in my code, a
test case provides the Lucene folks with something to work with.

sorry , am not clear with this.

The analyzer itself looks like it should do what you want on a cursory
inspection.....

Best
Erick

--
View this message in context: http://www.nabble.com/singular-and-plural-search-tp25990682p25992140.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene


m.harig at gmail

Oct 21, 2009, 6:22 AM

Post #4 of 5 (988 views)
Permalink
Re: singular and plural search [In reply to]

Thanks erick ,

It works fine , if i use the (code snippet found from nabble) same
analyzer for both indexing & querying .

But the highlighter has gone for plural words. Hope i need to search more ,
i'll come back to you once if i can't find out. Thanks again erick.
--
View this message in context: http://www.nabble.com/singular-and-plural-search-tp25990682p25992428.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene


mhall at informatics

Oct 21, 2009, 7:52 AM

Post #5 of 5 (993 views)
Permalink
Re: singular and plural search [In reply to]

If I recall correctly the highlighter also has an analyzer passed to
it. Ensure that this is the same one as well.

Matt

m.harig wrote:
> Thanks erick ,
>
> It works fine , if i use the (code snippet found from nabble) same
> analyzer for both indexing & querying .
>
> But the highlighter has gone for plural words. Hope i need to search more ,
> i'll come back to you once if i can't find out. Thanks again erick.
>



---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene

Lucene java-user RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.