Class SimpleSpanFragmenter
java.lang.Object
org.apache.lucene.search.highlight.SimpleSpanFragmenter
- All Implemented Interfaces:
Fragmenter
Fragmenter implementation which breaks text up into same-size fragments but does not
split up Spans. This is a simple sample class.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate static final intprivate intprivate OffsetAttributeprivate PositionIncrementAttributeprivate intprivate QueryScorerprivate CharTermAttributeprivate intprivate int -
Constructor Summary
ConstructorsConstructorDescriptionSimpleSpanFragmenter(QueryScorer queryScorer) SimpleSpanFragmenter(QueryScorer queryScorer, int fragmentSize) -
Method Summary
Modifier and TypeMethodDescriptionbooleanTest to see if this token from the stream should be held in a new TextFragment.voidstart(String originalText, TokenStream tokenStream) Initializes the Fragmenter.
-
Field Details
-
DEFAULT_FRAGMENT_SIZE
private static final int DEFAULT_FRAGMENT_SIZE- See Also:
-
fragmentSize
private int fragmentSize -
currentNumFrags
private int currentNumFrags -
position
private int position -
queryScorer
-
waitForPos
private int waitForPos -
textSize
private int textSize -
termAtt
-
posIncAtt
-
offsetAtt
-
-
Constructor Details
-
SimpleSpanFragmenter
- Parameters:
queryScorer- QueryScorer that was used to score hits
-
SimpleSpanFragmenter
- Parameters:
queryScorer- QueryScorer that was used to score hitsfragmentSize- size in chars of each fragment
-
-
Method Details
-
isNewFragment
public boolean isNewFragment()Description copied from interface:FragmenterTest to see if this token from the stream should be held in a new TextFragment. Every time this is called, the TokenStream passed to start(String, TokenStream) will have been incremented.- Specified by:
isNewFragmentin interfaceFragmenter
-
start
Description copied from interface:FragmenterInitializes the Fragmenter. You can grab references to the Attributes you are interested in from tokenStream and then access the values inFragmenter.isNewFragment().- Specified by:
startin interfaceFragmenter- Parameters:
originalText- the original source texttokenStream- theTokenStreamto be fragmented
-