java.lang.Object
com.lowagie.text.pdf.hyphenation.TernaryTree
com.lowagie.text.pdf.hyphenation.HyphenationTree
- All Implemented Interfaces:
PatternConsumer,Serializable,Cloneable
Deprecated.
This tree structure stores the hyphenation patterns in an efficient way for fast lookup. It provides the provides the
method to hyphenate a word.
- Author:
- Carlos Villegas
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.lowagie.text.pdf.hyphenation.TernaryTree
TernaryTree.Iterator -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected TernaryTreeDeprecated.This map stores the character classesDeprecated.This map stores hyphenation exceptionsprotected ByteVectorDeprecated.value space: stores the interletter valuesFields inherited from class com.lowagie.text.pdf.hyphenation.TernaryTree
BLOCK_SIZE, eq, freenode, hi, kv, length, lo, root, sc -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDeprecated.Add a character class to the tree.voidaddException(String word, ArrayList hyphenatedword) Deprecated.Add an exception to the tree.voidaddPattern(String pattern, String ivalue) Deprecated.Add a pattern to the tree.findPattern(String pat) Deprecated.protected byte[]getValues(int k) Deprecated.protected inthstrcmp(char[] s, int si, char[] t, int ti) Deprecated.String compare, returns 0 if equal or t is a substring of shyphenate(char[] w, int offset, int len, int remainCharCount, int pushCharCount) Deprecated.Hyphenate word and return an array of hyphenation points.Deprecated.Hyphenate word and return a Hyphenation object.voidloadSimplePatterns(InputStream stream) Deprecated.protected intpackValues(String values) Deprecated.Packs the values by storing them in 4 bits, two values into a byte Values range is from 0 to 9.voidDeprecated.protected voidsearchPatterns(char[] word, int index, byte[] il) Deprecated.Search for all possible partial matches of word starting at index an update interletter values.protected StringunpackValues(int k) Deprecated.
-
Field Details
-
vspace
Deprecated.value space: stores the interletter values -
stoplist
Deprecated.This map stores hyphenation exceptions -
classmap
Deprecated.This map stores the character classes
-
-
Constructor Details
-
HyphenationTree
public HyphenationTree()Deprecated.
-
-
Method Details
-
packValues
Deprecated.Packs the values by storing them in 4 bits, two values into a byte Values range is from 0 to 9. We use zero as terminator, so we'll add 1 to the value.- Parameters:
values- a string of digits from '0' to '9' representing the interletter values.- Returns:
- the index into the vspace array where the packed values are stored.
-
unpackValues
Deprecated. -
loadSimplePatterns
Deprecated. -
findPattern
Deprecated. -
hstrcmp
protected int hstrcmp(char[] s, int si, char[] t, int ti) Deprecated.String compare, returns 0 if equal or t is a substring of s- Parameters:
s- The first String to comparesi- The index to start at on String st- The second String to compareti- The index to start at on String t- Returns:
- 0 if equal or
-
getValues
protected byte[] getValues(int k) Deprecated. -
searchPatterns
protected void searchPatterns(char[] word, int index, byte[] il) Deprecated.Search for all possible partial matches of word starting at index an update interletter values. In other words, it does something like:
for(i=0; i<patterns.length; i++) { if ( word.substring(index).startsWidth(patterns[i]) ) { update_interletter_values(patterns[i]); } }But it is done in an efficient way since the patterns are stored in a ternary tree. In fact, this is the whole purpose of having the tree: doing this search without having to test every single pattern. The number of patterns for languages such as English range from 4000 to 10000. Thus, doing thousands of string comparisons for each word to hyphenate would be really slow without the tree. The tradeoff is memory, but using a ternary tree instead of a trie, almost halves the the memory used by Lout or TeX. It's also faster than using a hash table
- Parameters:
word- null terminated word to matchindex- start index from wordil- interletter values array to update
-
hyphenate
Deprecated.Hyphenate word and return a Hyphenation object.- Parameters:
word- the word to be hyphenatedremainCharCount- Minimum number of characters allowed before the hyphenation point.pushCharCount- Minimum number of characters allowed after the hyphenation point.- Returns:
- a
Hyphenationobject representing the hyphenated word or null if word is not hyphenated.
-
hyphenate
Deprecated.Hyphenate word and return an array of hyphenation points.- Parameters:
w- char array that contains the wordoffset- Offset to first character in wordlen- Length of wordremainCharCount- Minimum number of characters allowed before the hyphenation point.pushCharCount- Minimum number of characters allowed after the hyphenation point.- Returns:
- a
Hyphenationobject representing the hyphenated word or null if word is not hyphenated.
-
addClass
Deprecated.Add a character class to the tree. It is used bySimplePatternParseras callback to add character classes. Character classes define the valid word characters for hyphenation. If a word contains a character not defined in any of the classes, it is not hyphenated. It also defines a way to normalize the characters in order to compare them with the stored patterns. Usually pattern files use only lower case characters, in this case a class for letter 'a', for example, should be defined as "aA", the first character being the normalization char.- Specified by:
addClassin interfacePatternConsumer- Parameters:
chargroup- character group
-
addException
Deprecated.Add an exception to the tree. It is used bySimplePatternParserclass as callback to store the hyphenation exceptions.- Specified by:
addExceptionin interfacePatternConsumer- Parameters:
word- normalized wordhyphenatedword- a vector of alternating strings andhyphenobjects.
-
addPattern
Deprecated.Add a pattern to the tree. Mainly, to be used bySimplePatternParserclass as callback to add a pattern to the tree.- Specified by:
addPatternin interfacePatternConsumer- Parameters:
pattern- the hyphenation patternivalue- interletter weight values indicating the desirability and priority of hyphenating at a given point within the pattern. It should contain only digit characters. (i.e. '0' to '9').
-
printStats
public void printStats()Deprecated.- Overrides:
printStatsin classTernaryTree
-