|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opencms.search.documents.CmsHighlightFinder
Adapted from Maik Schreiber's LuceneTools.java,v 1.5 2001/10/16 07:25:55. Alterations include: + Changed to support Lucene 1.3 release (requires no change to Lucene code base but consequently no longer supports MultiTermQuery, RangeQuery and PrefixQuery highlighting currently) + Performance enhancement - CmsHighlightExtractor caches m_query m_terms and can therefore be called repeatedly to highlight multiple results more efficently + New feature: can extract the most relevant parts of large bodies of text - with user defined size of extracts
Constructor Summary | |
CmsHighlightFinder(I_CmsTermHighlighter highlighter,
org.apache.lucene.search.Query query,
org.apache.lucene.analysis.Analyzer analyzer)
|
Method Summary | |
java.lang.String[] |
getBestFragments(java.lang.String text,
int fragmentSize,
int maxNumFragments)
Highlights a text in accordance to the given m_query, extracting the most relevant sections. |
java.lang.String |
getBestFragments(java.lang.String text,
int fragmentSize,
int maxNumFragments,
java.lang.String separator)
Highlights a text in accordance to the given m_query and extracting the most relevant sections. |
static void |
getTerms(org.apache.lucene.search.Query query,
java.util.HashSet terms,
boolean prohibited)
Extracts all term texts of a given Query. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public CmsHighlightFinder(I_CmsTermHighlighter highlighter, org.apache.lucene.search.Query query, org.apache.lucene.analysis.Analyzer analyzer) throws java.io.IOException
highlighter
- I_TermHighlighter to use to highlight m_terms in the textquery
- Query which contains the m_terms to be highlighted in the textanalyzer
- Analyzer used to construct the Query
java.io.IOException
- if something goes wrongMethod Detail |
public static void getTerms(org.apache.lucene.search.Query query, java.util.HashSet terms, boolean prohibited) throws java.io.IOException
query
- Query to extract term texts fromterms
- HashSet where extracted term texts should be put into
(Elements: String)prohibited
- true
to extract "prohibited" m_terms, too
java.io.IOException
- if something goes wrongpublic java.lang.String[] getBestFragments(java.lang.String text, int fragmentSize, int maxNumFragments) throws java.io.IOException
text
- text to highlight m_terms infragmentSize
- the size in bytes of each fragment to be returnedmaxNumFragments
- the maximum number of fragments.
java.io.IOException
- if something goes wrongpublic java.lang.String getBestFragments(java.lang.String text, int fragmentSize, int maxNumFragments, java.lang.String separator) throws java.io.IOException
text
- text to highlight m_terms infragmentSize
- the size in bytes of each fragment to be returnedmaxNumFragments
- the maximum number of fragments.separator
- the separator used to intersperse the document fragments
(typically " ... ")
java.io.IOException
- if something goes wrong
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |