Class LengthGoalBreakIterator
- java.lang.Object
-
- java.text.BreakIterator
-
- org.apache.lucene.search.uhighlight.LengthGoalBreakIterator
-
- All Implemented Interfaces:
Cloneable
public class LengthGoalBreakIterator extends BreakIterator
Wraps anotherBreakIterator
to skip past breaks that would result in passages that are too short. It's still possible to get a short passage but only at the very end of the input text.Important: This is not a general purpose
BreakIterator
; it's only designed to work in a way compatible with theUnifiedHighlighter
. Some assumptions are checked with Java assertions.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Field Summary
-
Fields inherited from class java.text.BreakIterator
DONE
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
clone()
static LengthGoalBreakIterator
createClosestToLength(BreakIterator baseIter, int targetLength, float fragmentAlignment)
Breaks will be on averagetargetLength
apart; the closest break to this target (before or after) is chosen.static LengthGoalBreakIterator
createMinLength(BreakIterator baseIter, int minLength, float fragmentAlignment)
Breaks will be at leastminLength
apart (to the extent possible), while trying to position the match inside the fragment according tofragmentAlignment
.int
current()
int
first()
int
following(int matchEndIndex)
CharacterIterator
getText()
boolean
isBoundary(int offset)
int
last()
int
next()
int
next(int n)
int
preceding(int matchStartIndex)
int
previous()
void
setText(String newText)
void
setText(CharacterIterator newText)
String
toString()
-
Methods inherited from class java.text.BreakIterator
getAvailableLocales, getCharacterInstance, getCharacterInstance, getLineInstance, getLineInstance, getSentenceInstance, getSentenceInstance, getWordInstance, getWordInstance
-
-
-
-
Method Detail
-
createMinLength
public static LengthGoalBreakIterator createMinLength(BreakIterator baseIter, int minLength, float fragmentAlignment)
Breaks will be at leastminLength
apart (to the extent possible), while trying to position the match inside the fragment according tofragmentAlignment
.
-
createClosestToLength
public static LengthGoalBreakIterator createClosestToLength(BreakIterator baseIter, int targetLength, float fragmentAlignment)
Breaks will be on averagetargetLength
apart; the closest break to this target (before or after) is chosen. The match will be positioned according tofragmentAlignment
as much as possible.
-
clone
public Object clone()
- Overrides:
clone
in classBreakIterator
-
getText
public CharacterIterator getText()
- Specified by:
getText
in classBreakIterator
-
setText
public void setText(String newText)
- Overrides:
setText
in classBreakIterator
-
setText
public void setText(CharacterIterator newText)
- Specified by:
setText
in classBreakIterator
-
current
public int current()
- Specified by:
current
in classBreakIterator
-
first
public int first()
- Specified by:
first
in classBreakIterator
-
last
public int last()
- Specified by:
last
in classBreakIterator
-
next
public int next(int n)
- Specified by:
next
in classBreakIterator
-
next
public int next()
- Specified by:
next
in classBreakIterator
-
previous
public int previous()
- Specified by:
previous
in classBreakIterator
-
following
public int following(int matchEndIndex)
- Specified by:
following
in classBreakIterator
-
preceding
public int preceding(int matchStartIndex)
- Overrides:
preceding
in classBreakIterator
-
isBoundary
public boolean isBoundary(int offset)
- Overrides:
isBoundary
in classBreakIterator
-
-