public class HyphenationState extends Object
Hyphenator.hyphenate(String, int, int)| Modifier and Type | Field and Description |
|---|---|
private StringHasher |
hasher
The
StringHasher to use. |
private int[][] |
hashes
The hashes of all substrings of
normalizedWord. |
private char |
hyphen |
private static int |
MIN_PATTERN_LENGTH
The minimum length of a pattern.
|
private char[] |
normalizedWord
The normalized word.
|
private int |
offset
The offset where to start hyphenation in
word. |
private int[] |
rankings
|
private StringUtil |
stringUtil
The
StringUtil to use. |
private String |
word |
| Constructor and Description |
|---|
HyphenationState(String word,
String normalizedWord,
char hyphen,
int maxPatternLength,
int offset,
StringHasher hasher,
StringUtil stringUtil)
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
apply(HyphenationPattern pattern)
This is the heart of the hyphenation algorithm.
|
private void |
apply(HyphenationPattern pattern,
int pos)
This method applies the
pattern matching at the given offset. |
private int[] |
getHashes(int length)
This method gets the hashes of all substrings of the
normalized word that have the
given length. |
protected char[] |
getNormalizedWord()
This method gets the normalized word.
|
String |
getWord()
This method gets the word to hyphenate.
|
Hyphenation |
toHyphenation()
This method gets the
Hyphenation from this state. |
protected int[] |
toHyphenationPoints()
This method creates the
hyphenationPoints of a
hyphenated word. |
String |
toString()
This method generates a string with the given
word including the ranked hyphenation points. |
private static final int MIN_PATTERN_LENGTH
private final StringHasher hasher
StringHasher to use.private final StringUtil stringUtil
StringUtil to use.private final String word
private final char[] normalizedWord
private int[][] hashes
normalizedWord. The first index indicates the substring-length - 2, the
second is the offset in normalizedWord.private final int[] rankings
private final int offset
word.private final char hyphen
public HyphenationState(String word, String normalizedWord, char hyphen, int maxPatternLength, int offset, StringHasher hasher, StringUtil stringUtil)
word - is the word to hyphenate.normalizedWord - is the normalized word.hyphen - is the hyphen.maxPatternLength - is the maximum length of all patterns.offset - is the start-position in word. Typically 0.hasher - is the hash-algorithm. It should be fast. The same StringHasher needs to
be used for HyphenationPattern.getWordPartHash().stringUtil - is the StringUtil to use.private int[] getHashes(int length)
normalized word that have the
given length.length - is the length of the substrings to get hashes for.public void apply(HyphenationPattern pattern)
pattern is a substring
of thepattern - is the pattern to check and potentially apply.private void apply(HyphenationPattern pattern, int pos)
pattern matching at the given offset.pattern - is the matching pattern.pos - is the offset in the word to hyphenate.protected int[] toHyphenationPoints()
hyphenationPoints of a
hyphenated word.toHyphenation()public Hyphenation toHyphenation()
Hyphenation from this state.Hyphenation.public String getWord()
protected char[] getNormalizedWord()
word in normalized form (lower case) and
surrounded by HyphenationPattern.TERMINATOR.Copyright © 2001–2016 mmm-Team. All rights reserved.