lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r805645 - /lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java
Date Wed, 19 Aug 2009 01:16:23 GMT
Author: markrmiller
Date: Wed Aug 19 01:16:23 2009
New Revision: 805645

URL: http://svn.apache.org/viewvc?rev=805645&view=rev
Log:
Fix duplicate code and one version of getWeightedSpanTerms - should accept a TokenStream now
rather than a CachingTokenStream.
Also fixes getWeightedSpanTermsWithScores to intern the fieldname.

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

Modified: lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java?rev=805645&r1=805644&r2=805645&view=diff
==============================================================================
--- lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java
(original)
+++ lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java
Wed Aug 19 01:16:23 2009
@@ -328,22 +328,12 @@
    *          that caused hit
    * @param tokenStream
    *          of text to be highlighted
-   * @return
+   * @return Map containing WeightedSpanTerms
    * @throws IOException
    */
-  public Map getWeightedSpanTerms(Query query, CachingTokenFilter cachingTokenFilter)
+  public Map getWeightedSpanTerms(Query query, TokenStream tokenStream)
       throws IOException {
-    this.fieldName = null;
-    this.tokenStream = cachingTokenFilter;
-
-    Map terms = new PositionCheckingMap();
-    try {
-      extract(query, terms);
-    } finally {
-      closeReaders();
-    }
-
-    return terms;
+    return getWeightedSpanTerms(query, tokenStream, null);
   }
 
   /**
@@ -357,13 +347,15 @@
    *          of text to be highlighted
    * @param fieldName
    *          restricts Term's used based on field name
-   * @return
+   * @return Map containing WeightedSpanTerms
    * @throws IOException
    */
   public Map getWeightedSpanTerms(Query query, TokenStream tokenStream,
       String fieldName) throws IOException {
     if (fieldName != null) {
       this.fieldName = StringHelper.intern(fieldName);
+    } else {
+      this.fieldName = null;
     }
 
     Map terms = new PositionCheckingMap();
@@ -396,7 +388,11 @@
    */
   public Map getWeightedSpanTermsWithScores(Query query, TokenStream tokenStream, String
fieldName,
       IndexReader reader) throws IOException {
-    this.fieldName = fieldName;
+    if (fieldName != null) {
+      this.fieldName = StringHelper.intern(fieldName);
+    } else {
+      this.fieldName = null;
+    }
     this.tokenStream = tokenStream;
 
     Map terms = new PositionCheckingMap();



Mime
View raw message