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 ma...@apache.org on 2009/08/19 20:43:44 UTC
svn commit: r805923 - in
/lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight:
Encoder.java Fragmenter.java QueryScorer.java Scorer.java
SimpleSpanFragmenter.java WeightedSpanTermExtractor.java
Author: markrmiller
Date: Wed Aug 19 18:43:43 2009
New Revision: 805923
URL: http://svn.apache.org/viewvc?rev=805923&view=rev
Log:
improve Highlighter javadocs
Modified:
lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Encoder.java
lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Fragmenter.java
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/Scorer.java
lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/SimpleSpanFragmenter.java
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/Encoder.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Encoder.java?rev=805923&r1=805922&r2=805923&view=diff
==============================================================================
--- lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Encoder.java (original)
+++ lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Encoder.java Wed Aug 19 18:43:43 2009
@@ -17,7 +17,7 @@
/**
- * Encodes original text. The Encoder works with the Formatter to generate the output.
+ * Encodes original text. The Encoder works with the {@link Formatter} to generate output.
*
*/
public interface Encoder
Modified: lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Fragmenter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Fragmenter.java?rev=805923&r1=805922&r2=805923&view=diff
==============================================================================
--- lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Fragmenter.java (original)
+++ lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Fragmenter.java Wed Aug 19 18:43:43 2009
@@ -28,10 +28,10 @@
/**
* Initializes the Fragmenter. You can grab references to the Attributes you are
- * interested in from tokenStream and then access the values in isNewFragment.
+ * interested in from tokenStream and then access the values in {@link #isNewFragment()}.
*
- * @param originalText
- * @param tokenStream
+ * @param originalText the original source text
+ * @param tokenStream the {@link TokenStream} to be fragmented
*/
public void start(String originalText, TokenStream tokenStream);
Modified: lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/QueryScorer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/QueryScorer.java?rev=805923&r1=805922&r2=805923&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 Wed Aug 19 18:43:43 2009
@@ -10,13 +10,15 @@
import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
import org.apache.lucene.analysis.tokenattributes.TermAttribute;
import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.memory.MemoryIndex;
import org.apache.lucene.search.Query;
+import org.apache.lucene.search.spans.SpanQuery;
import org.apache.lucene.util.StringHelper;
/**
* {@link Scorer} implementation which scores text fragments by the number of
- * unique query terms found. This class converts appropriate Querys to
- * SpanQuerys and attempts to score only those terms that participated in
+ * unique query terms found. This class converts appropriate {@link Query}s to
+ * {@link SpanQuery}s and attempts to score only those terms that participated in
* generating the 'hit' on the document.
*/
public class QueryScorer implements Scorer {
@@ -36,8 +38,6 @@
/**
* @param query Query to use for highlighting
- *
- * @throws IOException
*/
public QueryScorer(Query query) {
init(query, null, null, true);
@@ -46,7 +46,6 @@
/**
* @param query Query to use for highlighting
* @param field Field to highlight - pass null to ignore fields
- * @throws IOException
*/
public QueryScorer(Query query, String field) {
init(query, field, null, true);
@@ -55,19 +54,20 @@
/**
* @param query Query to use for highlighting
* @param field Field to highlight - pass null to ignore fields
- *
- * @param reader
- * @throws IOException
+ * @param reader {@link IndexReader} to use for quasi tf/idf scoring
*/
public QueryScorer(Query query, IndexReader reader, String field) {
init(query, field, reader, true);
}
+
/**
- * As above, but with ability to pass in an <tt>IndexReader</tt>
+ * @param query to use for highlighting
+ * @param reader {@link IndexReader} to use for quasi tf/idf scoring
+ * @param field to highlight - pass null to ignore fields
+ * @param defaultField
*/
- public QueryScorer(Query query, IndexReader reader, String field, String defaultField)
- throws IOException {
+ public QueryScorer(Query query, IndexReader reader, String field, String defaultField) {
this.defaultField = StringHelper.intern(defaultField);
init(query, field, reader, true);
}
@@ -81,7 +81,7 @@
}
/**
- * @param weightedTerms
+ * @param weightedTerms an array of pre-created {@link WeightedSpanTerm}s
*/
public QueryScorer(WeightedSpanTerm[] weightedTerms) {
this.fieldWeightedSpanTerms = new HashMap(weightedTerms.length);
@@ -112,7 +112,7 @@
/**
*
* @return The highest weighted term (useful for passing to
- * GradientFormatter to set top end of coloring scale.
+ * GradientFormatter to set top end of coloring scale).
*/
public float getMaxTermWeight() {
return maxTermWeight;
@@ -151,6 +151,9 @@
return score;
}
+ /* (non-Javadoc)
+ * @see org.apache.lucene.search.highlight.Scorer#init(org.apache.lucene.analysis.TokenStream)
+ */
public TokenStream init(TokenStream tokenStream) throws IOException {
position = -1;
termAtt = (TermAttribute) tokenStream.getAttribute(TermAttribute.class);
@@ -165,10 +168,10 @@
}
/**
- * Retrieve the WeightedSpanTerm for the specified token. Useful for passing
- * Span information to a Fragmenter.
+ * Retrieve the {@link WeightedSpanTerm} for the specified token. Useful for passing
+ * Span information to a {@link Fragmenter}.
*
- * @param token
+ * @param token to get {@link WeightedSpanTerm} for
* @return WeightedSpanTerm for token
*/
public WeightedSpanTerm getWeightedSpanTerm(String token) {
@@ -180,7 +183,6 @@
* @param field
* @param tokenStream
* @param reader
- * @throws IOException
*/
private void init(Query query, String field, IndexReader reader, boolean expandMultiTermQuery) {
this.reader = reader;
@@ -218,10 +220,19 @@
totalScore = 0;
}
+ /**
+ * @return true if multi-term queries should be expanded
+ */
public boolean isExpandMultiTermQuery() {
return expandMultiTermQuery;
}
+ /**
+ * Controls whether or not multi-term queries are expanded
+ * against a {@link MemoryIndex} {@link IndexReader}.
+ *
+ * @param expandMultiTermQuery true if multi-term queries should be expanded
+ */
public void setExpandMultiTermQuery(boolean expandMultiTermQuery) {
this.expandMultiTermQuery = expandMultiTermQuery;
}
Modified: lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Scorer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Scorer.java?rev=805923&r1=805922&r2=805923&view=diff
==============================================================================
--- lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Scorer.java (original)
+++ lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Scorer.java Wed Aug 19 18:43:43 2009
@@ -22,44 +22,44 @@
import org.apache.lucene.analysis.TokenStream;
/**
- * Adds to the score for a fragment based on its tokens
+ * A Scorer is responsible for scoring a stream of tokens. These token scores
+ * can then be used to compute {@link TextFragment} scores.
*/
public interface Scorer {
/**
- * Called to init the Scorer with a TokenStream. You can grab references to
- * the attributes you are interested in here and access them from
- * getTokenScore().
+ * Called to init the Scorer with a {@link TokenStream}. You can grab references to
+ * the attributes you are interested in here and access them from {@link #getTokenScore()}.
*
- * @param tokenStream
- * @return either a TokenStream that the Highlighter should continue using (eg
+ * @param tokenStream the {@link TokenStream} that will be scored.
+ * @return either a {@link TokenStream} that the Highlighter should continue using (eg
* if you read the tokenSream in this method) or null to continue
- * using the same TokenStream that was passed in.
+ * using the same {@link TokenStream} that was passed in.
* @throws IOException
*/
public TokenStream init(TokenStream tokenStream) throws IOException;
/**
- * called when a new fragment is started for consideration
+ * Called when a new fragment is started for consideration.
*
- * @param newFragment
+ * @param newFragment the fragment that will be scored next
*/
public void startFragment(TextFragment newFragment);
/**
- * Called for each token in the current fragment. The Highlighter will
- * increment the TokenStream passed to init on every call.
+ * Called for each token in the current fragment. The {@link Highlighter} will
+ * increment the {@link TokenStream} passed to init on every call.
*
- * @return a score which is passed to the Highlighter class to influence the
+ * @return a score which is passed to the {@link Highlighter} class to influence the
* mark-up of the text (this return value is NOT used to score the
* fragment)
*/
public float getTokenScore();
/**
- * Called when the highlighter has no more tokens for the current fragment -
- * the scorer returns the weighting it has derived for the most recent
- * fragment, typically based on the tokens passed to getTokenScore().
+ * Called when the {@link Highlighter} has no more tokens for the current fragment -
+ * the Scorer returns the weighting it has derived for the most recent
+ * fragment, typically based on the results of {@link #getTokenScore()}.
*
*/
public float getFragmentScore();
Modified: lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/SimpleSpanFragmenter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/SimpleSpanFragmenter.java?rev=805923&r1=805922&r2=805923&view=diff
==============================================================================
--- lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/SimpleSpanFragmenter.java (original)
+++ lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/SimpleSpanFragmenter.java Wed Aug 19 18:43:43 2009
@@ -23,11 +23,12 @@
import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
import org.apache.lucene.analysis.tokenattributes.TermAttribute;
+import org.apache.lucene.search.spans.Spans;
/**
* {@link Fragmenter} implementation which breaks text up into same-size
- * fragments but does not split up Spans. This is a simple sample class.
+ * fragments but does not split up {@link Spans}. This is a simple sample class.
*/
public class SimpleSpanFragmenter implements Fragmenter {
private static final int DEFAULT_FRAGMENT_SIZE = 100;
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=805923&r1=805922&r2=805923&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 18:43:43 2009
@@ -53,7 +53,8 @@
import org.apache.lucene.util.StringHelper;
/**
- * Class used to extract {@link WeightedSpanTerm}s from a {@link Query} based on whether Terms from the query are contained in a supplied TokenStream.
+ * Class used to extract {@link WeightedSpanTerm}s from a {@link Query} based on whether
+ * {@link Term}s from the {@link Query} are contained in a supplied {@link TokenStream}.
*/
public class WeightedSpanTermExtractor {