Lucene.Net  3.0.3
Lucene.Net is a port of the Lucene search engine library, written in C# and targeted at .NET runtime users.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Pages
Public Member Functions | Static Public Attributes | Properties | List of all members
Lucene.Net.Search.Highlight.Highlighter Class Reference

Class used to markup highlighted terms found in the best sections of a text, using configurable IFragmenter, Scorer, IFormatter, IEncoder and tokenizers. More...

Public Member Functions

 Highlighter (IScorer fragmentScorer)
 
 Highlighter (IFormatter formatter, IScorer fragmentScorer)
 
 Highlighter (IFormatter formatter, IEncoder encoder, IScorer fragmentScorer)
 
String GetBestFragment (Analyzer analyzer, String fieldName, String text)
 Highlights chosen terms in a text, extracting the most relevant section. This is a convenience method that calls GetBestFragment(TokenStream, string)
 
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. After accumulating stats, the fragment with the highest score is returned
 
String[] GetBestFragments (Analyzer analyzer, String fieldName, String text, int maxNumFragments)
 Highlights chosen terms in a text, extracting the most relevant sections. This is a convenience method that calls GetBestFragments(TokenStream, string, int)
 
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. 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)
 
TextFragment[] GetBestTextFragments (TokenStream tokenStream, String text, bool mergeContiguousFragments, int maxNumFragments)
 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.
 
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. After accumulating stats, the fragments with the highest scores are returned in order as "separator" delimited strings.
 

Static Public Attributes

static readonly int DEFAULT_MAX_CHARS_TO_ANALYZE = 50*1024
 

Properties

int MaxDocCharsToAnalyze [get, set]
 
IFragmenter TextFragmenter [get, set]
 
IScorer FragmentScorer [get, set]
 
IEncoder Encoder [get, set]
 

Detailed Description

Class used to markup highlighted terms found in the best sections of a text, using configurable IFragmenter, Scorer, IFormatter, IEncoder and tokenizers.

Definition at line 34 of file Highlighter.cs.

Constructor & Destructor Documentation

Lucene.Net.Search.Highlight.Highlighter.Highlighter ( IScorer  fragmentScorer)

Definition at line 44 of file Highlighter.cs.

Lucene.Net.Search.Highlight.Highlighter.Highlighter ( IFormatter  formatter,
IScorer  fragmentScorer 
)

Definition at line 50 of file Highlighter.cs.

Lucene.Net.Search.Highlight.Highlighter.Highlighter ( IFormatter  formatter,
IEncoder  encoder,
IScorer  fragmentScorer 
)

Definition at line 56 of file Highlighter.cs.

Member Function Documentation

String Lucene.Net.Search.Highlight.Highlighter.GetBestFragment ( Analyzer  analyzer,
String  fieldName,
String  text 
)

Highlights chosen terms in a text, extracting the most relevant section. This is a convenience method that calls GetBestFragment(TokenStream, string)

Parameters
analyzerthe analyzer that will be used to split text into chunks
fieldNameName of field used to influence analyzer's tokenization policy
texttext to highlight terms in
Returns
highlighted text fragment or null if no terms found
Exceptions
InvalidTokenOffsetsExceptionthrown if any token's endOffset exceeds the provided text's length

Definition at line 72 of file Highlighter.cs.

String Lucene.Net.Search.Highlight.Highlighter.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. After accumulating stats, the fragment with the highest score is returned

Parameters
tokenStreama stream of tokens identified in the text parameter, including offset information. This is typically produced by an analyzer re-parsing a document's text. Some work may be done on retrieving TokenStreams more efficiently by adding support for storing original text position data in the Lucene index but this support is not currently available (as of Lucene 1.4 rc2).
texttext to highlight terms in
Returns
highlighted text fragment or null if no terms found
Exceptions
InvalidTokenOffsetsExceptionthrown if any token's endOffset exceeds the provided text's length

Definition at line 94 of file Highlighter.cs.

String [] Lucene.Net.Search.Highlight.Highlighter.GetBestFragments ( Analyzer  analyzer,
String  fieldName,
String  text,
int  maxNumFragments 
)

Highlights chosen terms in a text, extracting the most relevant sections. This is a convenience method that calls GetBestFragments(TokenStream, string, int)

Parameters
analyzerthe analyzer that will be used to split text into chunks
fieldNamethe name of the field being highlighted (used by analyzer)
texttext to highlight terms in
maxNumFragmentsthe maximum number of fragments.
Returns
highlighted text fragments (between 0 and maxNumFragments number of fragments)
Exceptions
InvalidTokenOffsetsExceptionthrown if any token's endOffset exceeds the provided text's length

Definition at line 114 of file Highlighter.cs.

String [] Lucene.Net.Search.Highlight.Highlighter.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. 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
tokenStream
texttext to highlight terms in
maxNumFragmentsthe maximum number of fragments.
Returns
highlighted text fragments (between 0 and maxNumFragments number of fragments)
Exceptions
InvalidTokenOffsetsExceptionthrown if any token's endOffset exceeds the provided text's length

Definition at line 136 of file Highlighter.cs.

String Lucene.Net.Search.Highlight.Highlighter.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. After accumulating stats, the fragments with the highest scores are returned in order as "separator" delimited strings.

Parameters
tokenStream
texttext to highlight terms in
maxNumFragmentsthe maximum number of fragments.
separatorthe separator used to intersperse the document fragments (typically "...")
Returns
highlighted text

Definition at line 417 of file Highlighter.cs.

TextFragment [] Lucene.Net.Search.Highlight.Highlighter.GetBestTextFragments ( TokenStream  tokenStream,
String  text,
bool  mergeContiguousFragments,
int  maxNumFragments 
)

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.

Definition at line 159 of file Highlighter.cs.

Member Data Documentation

readonly int Lucene.Net.Search.Highlight.Highlighter.DEFAULT_MAX_CHARS_TO_ANALYZE = 50*1024
static

Definition at line 36 of file Highlighter.cs.

Property Documentation

IEncoder Lucene.Net.Search.Highlight.Highlighter.Encoder
getset

Definition at line 456 of file Highlighter.cs.

IScorer Lucene.Net.Search.Highlight.Highlighter.FragmentScorer
getset

Definition at line 450 of file Highlighter.cs.

int Lucene.Net.Search.Highlight.Highlighter.MaxDocCharsToAnalyze
getset

Definition at line 437 of file Highlighter.cs.

IFragmenter Lucene.Net.Search.Highlight.Highlighter.TextFragmenter
getset

Definition at line 444 of file Highlighter.cs.


The documentation for this class was generated from the following file: