lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mharw...@apache.org
Subject svn commit: r279088 - in /lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight: QueryScorer.java SimpleHTMLEncoder.java
Date Tue, 06 Sep 2005 20:20:13 GMT
Author: mharwood
Date: Tue Sep  6 13:19:50 2005
New Revision: 279088

URL: http://svn.apache.org/viewcvs?rev=279088&view=rev
Log:
Added fix to QueryScorer - if a query has multiple WeightedTerms with different weights for
the same term the highest weight is used for scoring that term (previously selected last weight
in list)

SimpleHTMLEncoder now encodes characters outside of ASCII range as character entities as per
suggestion here: http://issues.apache.org/bugzilla/show_bug.cgi?id=36333

Modified:
    lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/QueryScorer.java
    lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/SimpleHTMLEncoder.java

Modified: lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/QueryScorer.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/QueryScorer.java?rev=279088&r1=279087&r2=279088&view=diff
==============================================================================
--- lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/QueryScorer.java
(original)
+++ lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/QueryScorer.java
Tue Sep  6 13:19:50 2005
@@ -67,8 +67,13 @@
 		termsToFind = new HashMap();
 		for (int i = 0; i < weightedTerms.length; i++)
 		{
-			termsToFind.put(weightedTerms[i].term,weightedTerms[i]);
-			maxTermWeight=Math.max(maxTermWeight,weightedTerms[i].getWeight());
+			WeightedTerm existingTerm=(WeightedTerm) termsToFind.get(weightedTerms[i].term);
+			if( (existingTerm==null) ||(existingTerm.weight<weightedTerms[i].weight) )
+			{
+				//if a term is defined more than once, always use the highest scoring weight
+				termsToFind.put(weightedTerms[i].term,weightedTerms[i]);
+				maxTermWeight=Math.max(maxTermWeight,weightedTerms[i].getWeight());
+			}
 		}
 	}
 	

Modified: lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/SimpleHTMLEncoder.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/SimpleHTMLEncoder.java?rev=279088&r1=279087&r2=279088&view=diff
==============================================================================
--- lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/SimpleHTMLEncoder.java
(original)
+++ lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/SimpleHTMLEncoder.java
Tue Sep  6 13:19:50 2005
@@ -66,7 +66,14 @@
 				break;
 
 			default:
-				result.append(ch);
+				   if (ch < 128) 
+				   {
+			           result.append(ch);
+			       } 
+				   else 
+			       {
+			           result.append("&#").append((int)ch).append(";");
+			       }
 			}
 		}
 



Mime
View raw message