You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Alf Eaton <li...@hubmed.org> on 2007/08/16 16:17:00 UTC

Stemmed terms/common terms

A couple of questions about term frequencies and stemming:

- What's the best way to get the most common unstemmed form of a  
Porter-stemmed word from the index? For example given the stem  
'walk', find that 'walking' is the most common full word in the index.

- Is there a way to get a list of all the terms in the index (or  
maybe just the top n) ordered by descending frequency of usage? I  
imagine it's related to docFreq, but can't see how to get a list of  
terms in all documents.

I'm using PyLucene and Solr, so if there are easy solutions in either  
of those that would be ideal.

Thanks,
alf.



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


Re: Stemmed terms/common terms

Posted by Alf Eaton <li...@hubmed.org>.
On 16 Aug 2007, at 15:17, Alf Eaton wrote:
>
> - Is there a way to get a list of all the terms in the index (or  
> maybe just the top n) ordered by descending frequency of usage? I  
> imagine it's related to docFreq, but can't see how to get a list of  
> terms in all documents.

Thanks to http://tinyurl.com/2gndww I worked out how to do this (to  
get a list of terms and their frequency) with PyLucene:

terms = reader.terms()
while terms.next():
   term = terms.term()
   if term.field() == 'title':
     print '%s - %d' % (term.text(), reader.docFreq(term))


alf.

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


Re: Stemmed terms/common terms

Posted by Alf Eaton <li...@hubmed.org>.
On 16 Aug 2007, at 17:06, Grant Ingersoll wrote:

>
> On Aug 16, 2007, at 10:17 AM, Alf Eaton wrote:
>
>> A couple of questions about term frequencies and stemming:
>>
>> - What's the best way to get the most common unstemmed form of a  
>> Porter-stemmed word from the index? For example given the stem  
>> 'walk', find that 'walking' is the most common full word in the  
>> index.
>
> Are both in the index?  I would think this is going to take some  
> application specific logic, since Lucene doesn't inherently track  
> these relations.  You might be able to string something together  
> using some of the regular expression/wildcard queries, but it is  
> going to take some work on your part.

Hmm, no - the stemmed token is indexed and the full field is stored.  
I guess that means running a search for the stem and then using the  
same logic as a highlighter to find and extract the actual terms from  
each document.

> Another approach might be to put some mechanisms in place during  
> analysis that track this information.

How would you recommend doing this - using positionIncrement to store  
the stem and the original word at the same position, perhaps?

alf.

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


Re: Stemmed terms/common terms

Posted by Grant Ingersoll <gs...@apache.org>.
On Aug 16, 2007, at 10:17 AM, Alf Eaton wrote:

> A couple of questions about term frequencies and stemming:
>
> - What's the best way to get the most common unstemmed form of a  
> Porter-stemmed word from the index? For example given the stem  
> 'walk', find that 'walking' is the most common full word in the index.

Are both in the index?  I would think this is going to take some  
application specific logic, since Lucene doesn't inherently track  
these relations.  You might be able to string something together  
using some of the regular expression/wildcard queries, but it is  
going to take some work on your part.

Another approach might be to put some mechanisms in place during  
analysis that track this information.

>
> - Is there a way to get a list of all the terms in the index (or  
> maybe just the top n) ordered by descending frequency of usage? I  
> imagine it's related to docFreq, but can't see how to get a list of  
> terms in all documents.

Have a look at Luke if you just want the info as part of a UI.  Also,  
I _believe_ Solr has added a LukeRequestHandler (see http:// 
wiki.apache.org/solr/LukeRequestHandler), not sure if it does  
everything you are looking for, but it might be a place to start.   
You might ask your question on the Solr mailing list.

>
> I'm using PyLucene and Solr, so if there are easy solutions in  
> either of those that would be ideal.
>
> Thanks,
> alf.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>

--------------------------
Grant Ingersoll
http://lucene.grantingersoll.com

Lucene Helpful Hints:
http://wiki.apache.org/lucene-java/BasicsOfPerformance
http://wiki.apache.org/lucene-java/LuceneFAQ



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