| java.lang.Object org.apache.lucene.search.highlight.Highlighter
Highlighter | public class Highlighter (Code) | | Class used to markup highlighted terms found in the best sections of a text,
using configurable
Fragmenter ,
Scorer ,
Formatter ,
Encoder and tokenizers.
author: mark@searcharea.co.uk |
Method Summary | |
final public String | getBestFragment(Analyzer analyzer, String fieldName, String text) Highlights chosen terms in a text, extracting the most relevant section. | final public String | getBestFragment(TokenStream tokenStream, String text) Highlights chosen terms in a text, extracting the most relevant section.
The document text is analysed in chunks to record hit statistics across
the document. | final public String[] | getBestFragments(Analyzer analyzer, String text, int maxNumFragments) Highlights chosen terms in a text, extracting the most relevant sections.
This is a convenience method that calls
Highlighter.getBestFragments(TokenStream,String,int) Parameters: analyzer - the analyzer that will be used to split text intochunks Parameters: text - text to highlight terms in Parameters: maxNumFragments - the maximum number of fragments. | final public String[] | getBestFragments(TokenStream tokenStream, String text, int maxNumFragments) Highlights chosen terms in a text, extracting the most relevant sections.
The document text is analysed in chunks to record hit statistics across
the document. | final public String | getBestFragments(TokenStream tokenStream, String text, int maxNumFragments, String separator) Highlights terms in the text , extracting the most relevant sections and
concatenating the chosen fragments with a separator (typically "...").
The document text is analysed in chunks to record hit statistics across
the document. | final public TextFragment[] | getBestTextFragments(TokenStream tokenStream, String text, boolean mergeContiguousFragments, int maxNumFragments) Low level api to get the most relevant (formatted) sections of the
document. | public Encoder | getEncoder() | public Scorer | getFragmentScorer() | public int | getMaxDocBytesToAnalyze() | public Fragmenter | getTextFragmenter() | public void | setEncoder(Encoder encoder) | public void | setFragmentScorer(Scorer scorer) | public void | setMaxDocBytesToAnalyze(int byteCount) | public void | setTextFragmenter(Fragmenter fragmenter) |
DEFAULT_MAX_DOC_BYTES_TO_ANALYZE | final public static int DEFAULT_MAX_DOC_BYTES_TO_ANALYZE(Code) | | |
getBestFragment | final public String getBestFragment(Analyzer analyzer, String fieldName, String text) throws IOException(Code) | | Highlights chosen terms in a text, extracting the most relevant section.
This is a convenience method that calls
Highlighter.getBestFragment(TokenStream,String) Parameters: analyzer - the analyzer that will be used to split text intochunks Parameters: text - text to highlight terms in Parameters: fieldName - Name of field used to influence analyzer's tokenization policy highlighted text fragment or null if no terms found |
getBestFragment | final public String getBestFragment(TokenStream tokenStream, String text) throws IOException(Code) | | Highlights chosen terms in a text, extracting the most relevant section.
The document text is analysed in chunks to record hit statistics across
the document. After accumulating stats, the fragment with the highest
score is returned
Parameters: tokenStream - a stream of tokens identified in the text parameter, includingoffset information. This is typically produced by an analyzerre-parsing a document's text. Some work may be done on retrievingTokenStreams more efficently by adding support for storingoriginal text position data in the Lucene index but this supportis not currently available (as of Lucene 1.4 rc2). Parameters: text - text to highlight terms in highlighted text fragment or null if no terms found |
getBestFragments | final public String[] getBestFragments(Analyzer analyzer, String text, int maxNumFragments) throws IOException(Code) | | Highlights chosen terms in a text, extracting the most relevant sections.
This is a convenience method that calls
Highlighter.getBestFragments(TokenStream,String,int) Parameters: analyzer - the analyzer that will be used to split text intochunks Parameters: text - text to highlight terms in Parameters: maxNumFragments - the maximum number of fragments. highlighted text fragments (between 0 and maxNumFragments numberof fragments) |
getBestFragments | final public String[] getBestFragments(TokenStream tokenStream, String text, int maxNumFragments) throws IOException(Code) | | Highlights chosen terms in a text, extracting the most relevant sections.
The document text is analysed in chunks to record hit statistics across
the document. After accumulating stats, the fragments with the highest
scores are returned as an array of strings in order of score (contiguous
fragments are merged into one in their original order to improve
readability)
Parameters: text - text to highlight terms in Parameters: maxNumFragments - the maximum number of fragments. highlighted text fragments (between 0 and maxNumFragments numberof fragments) |
getBestFragments | final public String getBestFragments(TokenStream tokenStream, String text, int maxNumFragments, String separator) throws IOException(Code) | | Highlights terms in the text , extracting the most relevant sections and
concatenating the chosen fragments with a separator (typically "...").
The document text is analysed in chunks to record hit statistics across
the document. After accumulating stats, the fragments with the highest
scores are returned in order as "separator" delimited strings.
Parameters: text - text to highlight terms in Parameters: maxNumFragments - the maximum number of fragments. Parameters: separator - the separator used to intersperse the document fragments(typically "...") highlighted text |
getBestTextFragments | final public TextFragment[] getBestTextFragments(TokenStream tokenStream, String text, boolean mergeContiguousFragments, int maxNumFragments) throws IOException(Code) | | Low level api to get the most relevant (formatted) sections of the
document. This method has been made public to allow visibility of score
information held in TextFragment objects. Thanks to Jason Calabrese for
help in redefining the interface.
Parameters: tokenStream - Parameters: text - Parameters: maxNumFragments - Parameters: mergeContiguousFragments - throws: IOException - |
getFragmentScorer | public Scorer getFragmentScorer()(Code) | | Object used to score each text fragment |
getMaxDocBytesToAnalyze | public int getMaxDocBytesToAnalyze()(Code) | | the maximum number of bytes to be tokenized per doc |
setFragmentScorer | public void setFragmentScorer(Scorer scorer)(Code) | | Parameters: scorer - |
setMaxDocBytesToAnalyze | public void setMaxDocBytesToAnalyze(int byteCount)(Code) | | Parameters: byteCount - the maximum number of bytes to be tokenized per doc (This canimprove performance with large documents) |
setTextFragmenter | public void setTextFragmenter(Fragmenter fragmenter)(Code) | | Parameters: fragmenter - |
|
|