Author: dnaber Date: Wed Feb 16 12:37:57 2005 New Revision: 154083 URL: http://svn.apache.org/viewcvs?view=rev&rev=154083 Log: remove empty "@return" tags so javadoc stops complaining; small whitespace cleanup
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/Formatter.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/Highlighter.java lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/TokenGroup.java lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/package.html Modified: lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Encoder.java URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Encoder.java?view=diff&r1=154082&r2=154083 ============================================================================== --- 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 Feb 16 12:37:57 2005 @@ -25,7 +25,6 @@ { /** * @param originalText The section of text being output - * @return */ String encodeText(String originalText); } Modified: lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Formatter.java URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Formatter.java?view=diff&r1=154082&r2=154083 ============================================================================== --- lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Formatter.java (original) +++ lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Formatter.java Wed Feb 16 12:37:57 2005 @@ -27,7 +27,6 @@ * @param originalText The section of text being considered for markup * @param tokenGroup contains one or several overlapping Tokens along with * their scores and positions. - * @return */ String highlightTerm(String originalText, TokenGroup tokenGroup); } Modified: lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Fragmenter.java URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Fragmenter.java?view=diff&r1=154082&r2=154083 ============================================================================== --- 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 Feb 16 12:37:57 2005 @@ -34,7 +34,6 @@ /** * Test to see if this token from the stream should be held in a new TextFragment * @param nextToken - * @return */ public boolean isNewFragment(Token nextToken); } Modified: lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Highlighter.java URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Highlighter.java?view=diff&r1=154082&r2=154083 ============================================================================== --- lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Highlighter.java (original) +++ lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/Highlighter.java Wed Feb 16 12:37:57 2005 @@ -127,7 +127,6 @@ * @param text * @param maxNumFragments * @param mergeContiguousFragments - * @return * @throws IOException */ public final TextFragment[] getBestTextFragments( @@ -411,7 +410,6 @@ } /** - * @return */ public Fragmenter getTextFragmenter() { Modified: lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/TokenGroup.java URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/TokenGroup.java?view=diff&r1=154082&r2=154083 ============================================================================== --- lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/TokenGroup.java (original) +++ lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/TokenGroup.java Wed Feb 16 12:37:57 2005 @@ -105,7 +105,7 @@ } /** - * @return + * @return all tokens' scores summed up */ public float getTotalScore() { Modified: lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/package.html URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/package.html?view=diff&r1=154082&r2=154083 ============================================================================== --- lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/package.html (original) +++ lucene/java/trunk/contrib/highlighter/src/java/org/apache/lucene/search/highlight/package.html Wed Feb 16 12:37:57 2005 @@ -1,51 +1,57 @@ <html> <body> + The highlight package contains classes to provide "keyword in context" features -typically used to highlight search terms in the text of results pages. <br> +typically used to highlight search terms in the text of results pages. The Highlighter class is the central component and can be used to extract the most interesting sections of a piece of text and highlight them, with the help of Fragmenter, FragmentScorer, Formatter classes. + <h2>Example Usage</h2> <pre> - IndexSearcher searcher = new IndexSearcher(ramDir); - Query query = QueryParser.parse("Kenne*", FIELD_NAME, analyzer); - query=query.rewrite(reader); //required to expand search terms - Hits hits = searcher.search(query); - - Highlighter highlighter =new Highlighter(this,new QueryScorer(query)); - for (int i = 0; i < hits.length(); i++) - { - String text = hits.doc(i).get(FIELD_NAME); - TokenStream tokenStream=analyzer.tokenStream(FIELD_NAME,new StringReader(text)); - // Get 3 best fragments and seperate with a "..." - String result = highlighter.getBestFragments(tokenStream,text,3,"..."); - System.out.println(result); - } + IndexSearcher searcher = new IndexSearcher(ramDir); + Query query = QueryParser.parse("Kenne*", FIELD_NAME, analyzer); + query = query.rewrite(reader); //required to expand search terms + Hits hits = searcher.search(query); + + Highlighter highlighter = new Highlighter(this, new QueryScorer(query)); + for (int i = 0; i < hits.length(); i++) + { + String text = hits.doc(i).get(FIELD_NAME); + TokenStream tokenStream = analyzer.tokenStream(FIELD_NAME, new StringReader(text)); + // Get 3 best fragments and seperate with a "..." + String result = highlighter.getBestFragments(tokenStream, text, 3, "..."); + System.out.println(result); + } </pre> + <h2>New features 06/02/2005</h2> + This release adds options for encoding (thanks to Nicko Cadell). An "Encoder" implementation such as the new SimpleHTMLEncoder class can be passed to the highlighter to encode all those non-xhtml standard characters such as & into legal values. This simple class may not suffice for some languages - Commons Lang has an implementation that could be used: escapeHtml(String) in http://svn.apache.org/viewcvs.cgi/jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringEscapeUtils.java?rev=137958&view=markup - - <h2>New features 22/12/2004</h2> + This release adds some new capabilities: <ol> <li>Faster highlighting using Term vector support</li> <li>New formatting options to use color intensity to show informational value</li> <li>Options for better summarization by using term IDF scores to influence fragment selection</li> </ol> + <p> The highlighter takes a TokenStream as input. Until now these streams have typically been produced using an Analyzer but the new class TokenSources provides helper methods for obtaining TokenStreams from the new TermVector position support (see latest CVS version).</p> + <p>The new class GradientFormatter can use a scale of colors to highlight terms according to their score. A subtle use of color can help emphasise the reasons for matching (useful when doing "MoreLikeThis" queries and -you want to see what the basis of the similarities are)</p> +you want to see what the basis of the similarities are).</p> + <p>The QueryScorer class has a new constructor which can use an IndexReader to derive the IDF (inverse document frequency) for each term in order to influcence the score. This is useful for helping to extracting the most significant sections of a document and in supplying scores used by the new GradientFormatter to color significant words more strongly. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]