|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.text.BreakDictionary
This is the class that represents the list of known words used by DictionaryBasedBreakIterator. The conceptual data structure used here is a trie: there is a node hanging off the root node for every letter that can start a word. Each of these nodes has a node hanging off of it for every letter that can be the second letter of a word if this node is the first letter, and so on. The trie is represented as a two-dimensional array that can be treated as a table of state transitions. Indexes are used to compress this array, taking advantage of the fact that this array will always be very sparse.
Field Summary | |
private sun.text.CompactByteArray |
columnMap
Maps from characters to column numbers. |
private int |
numColGroups
Columns are organized into groups of 32. |
private int |
numCols
The number of actual columns in the table |
private char[] |
reverseColumnMap
A map used to go from column numbers to characters. |
private short[] |
rowIndex
This index maps logical row numbers to physical row numbers |
private int[] |
rowIndexFlags
A bitmap is used to tell which cells in the comceptual table are populated. |
private short[] |
rowIndexFlagsIndex
This index maps from a logical row number into the bitmap table above. |
private byte[] |
rowIndexShifts
For each logical row, this index contains a constant that is added to the logical column number to get the physical column number |
private static int |
supportedVersion
The version of the dictionary that was read in. |
private short[] |
table
The actual compressed state table. |
private int |
version
|
Constructor Summary | |
BreakDictionary(InputStream dictionaryStream)
|
Method Summary | |
short |
at(int row,
char ch)
Uses the column map to map the character to a column number, then passes the row and column number to the other version of at() |
short |
at(int row,
int col)
Returns the value in the cell with the specified (logical) row and column numbers. |
private boolean |
cellIsPopulated(int row,
int col)
Given (logical) row and column numbers, returns true if the cell in that position is populated |
private short |
internalAt(int row,
int col)
Implementation of at() when we know the specified cell is populated. |
static void |
main(String[] args)
|
void |
printWordList(String partialWord,
int state,
PrintWriter out)
|
void |
readDictionaryFile(DataInputStream in)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private char[] reverseColumnMap
private static int supportedVersion
private int version
private sun.text.CompactByteArray columnMap
private int numCols
private int numColGroups
private short[] table
private short[] rowIndex
private int[] rowIndexFlags
private short[] rowIndexFlagsIndex
private byte[] rowIndexShifts
Constructor Detail |
public BreakDictionary(InputStream dictionaryStream) throws IOException
Method Detail |
public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException, IOException
FileNotFoundException
UnsupportedEncodingException
IOException
public void printWordList(String partialWord, int state, PrintWriter out) throws IOException
IOException
public void readDictionaryFile(DataInputStream in) throws IOException
IOException
public final short at(int row, char ch)
row
- The current statech
- The character whose column we're interested in
public final short at(int row, int col)
row
- The row number of the current statecol
- The column number of the input character (0 means "not a
dictionary character")
private final boolean cellIsPopulated(int row, int col)
private final short internalAt(int row, int col)
row
- The PHYSICAL row number of the cellcol
- The PHYSICAL column number of the cell
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |