Method GetBestFragment
GetBestFragment(Analyzer, String, String)
Highlights chosen terms in a text, extracting the most relevant section. This is a convenience method that calls GetBestFragment(TokenStream, String)
Declaration
public string GetBestFragment(Analyzer analyzer, string fieldName, string text)
Parameters
Type | Name | Description |
---|---|---|
Analyzer | analyzer | the analyzer that will be used to split |
System.String | fieldName | Name of field used to influence analyzer's tokenization policy |
System.String | text | text to highlight terms in |
Returns
Type | Description |
---|---|
System.String | highlighted text fragment or null if no terms found |
Exceptions
Type | Condition |
---|---|
InvalidTokenOffsetsException | thrown if any token's EndOffset exceeds the provided text's length |
GetBestFragment(TokenStream, String)
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
Declaration
public string GetBestFragment(TokenStream tokenStream, string text)
Parameters
Type | Name | Description |
---|---|---|
TokenStream | tokenStream | A 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). |
System.String | text | text to highlight terms in |
Returns
Type | Description |
---|---|
System.String | highlighted text fragment or null if no terms found |
Exceptions
Type | Condition |
---|---|
InvalidTokenOffsetsException | thrown if any token's EndOffset exceeds the provided text's length |