You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by ds...@apache.org on 2005/05/10 21:10:29 UTC

svn commit: r169511 - /lucene/java/trunk/contrib/similarity/src/java/org/apache/lucene/search/similar/MoreLikeThis.java

Author: dspencer
Date: Tue May 10 12:10:28 2005
New Revision: 169511

URL: http://svn.apache.org/viewcvs?rev=169511&view=rev
Log:
Touchup javadoc.
Make retrieveInterestingTerms only return the top terms, not all terms.


Modified:
    lucene/java/trunk/contrib/similarity/src/java/org/apache/lucene/search/similar/MoreLikeThis.java

Modified: lucene/java/trunk/contrib/similarity/src/java/org/apache/lucene/search/similar/MoreLikeThis.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/similarity/src/java/org/apache/lucene/search/similar/MoreLikeThis.java?rev=169511&r1=169510&r2=169511&view=diff
==============================================================================
--- lucene/java/trunk/contrib/similarity/src/java/org/apache/lucene/search/similar/MoreLikeThis.java (original)
+++ lucene/java/trunk/contrib/similarity/src/java/org/apache/lucene/search/similar/MoreLikeThis.java Tue May 10 12:10:28 2005
@@ -799,7 +799,7 @@
 
     /**
      * Find words for a more-like-this query former.
-	 * The result is a priority queue of arrays.
+	 * The result is a priority queue of arrays with one entry for <b>every word</b> in the document.
 	 * Each array has 6 elements.
 	 * The elements are:
 	 * <ol>
@@ -815,7 +815,8 @@
 	 * For an easier method to call see {@link #retrieveInterestingTerms retrieveInterestingTerms()}.
      *
      * @param r the reader that has the content of the document
-	 * @return the most intresting words in the document
+	 * @return the most intresting words in the document ordered by score, with the highest scoring, or best entry, first
+	 *
 	 * @see #retrieveInterestingTerms
      */
     public PriorityQueue retrieveTerms(Reader r) throws IOException {
@@ -840,7 +841,9 @@
 		ArrayList al = new ArrayList( maxQueryTerms);
 		PriorityQueue pq = retrieveTerms( r);
 		Object cur;
-		while (((cur = pq.pop()) != null)) {
+		int lim = maxQueryTerms; // have to be careful, retrieveTerms returns all words but that's probably not useful to our caller...
+		// we just want to return the top words
+		while (((cur = pq.pop()) != null) && lim-- > 0) {
             Object[] ar = (Object[]) cur;
 			al.add( ar[ 0]); // the 1st entry is the interesting word
 		}