public class WordMap
extends Object
Modifier and Type | Field and Description |
---|---|
private ArrayList |
blockHeads
Sorted list of the block keys, for fast binary searching
|
private HashMap |
blockMap
Map of blocks, keyed by the first word in each block
|
private FastCache |
cache
Keep a cache of lookups performed to-date
|
private static int |
CACHE_SIZE
How many recent mappings to maintain
|
Constructor and Description |
---|
WordMap(File f,
CharMap charMap)
Construct a word map by reading in a file.
|
WordMap(InputStream s,
CharMap charMap)
Construct a word map by reading from an InputStream.
|
Modifier and Type | Method and Description |
---|---|
String |
lookup(String word)
Look up a word, and return the corresponding value, or null if none.
|
private void |
readFile(BufferedReader reader,
CharMap charMap)
Read in the contents of a word file, forming blocks of 128 entries per
block.
|
private static final int CACHE_SIZE
private FastCache cache
private HashMap blockMap
private ArrayList blockHeads
public WordMap(File f, CharMap charMap) throws IOException
IOException
public WordMap(InputStream s, CharMap charMap) throws IOException
IOException
public String lookup(String word)
private void readFile(BufferedReader reader, CharMap charMap) throws IOException
reader
- Reader to get the data fromcharMap
- Accent map to filter entries with, or null for none.IOException