public class StringDictionary extends Object
Modifier and Type | Class and Description |
---|---|
static class |
StringDictionary.IndexAndCount |
Constructor and Description |
---|
StringDictionary(String name) |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
String |
get(int idx)
Reverse mapping from integer key to string value
|
int |
get(String s) |
int |
get(String s,
boolean shouldThrow)
Fetches the index of this string If mCreate is true, the entry is created
if it does not exist.
|
int |
getCount(int idx) |
StringDictionary.IndexAndCount |
getIndexAndCount(String s) |
Set<String> |
keys() |
Set<String> |
keySet() |
void |
load(String path,
String prefix)
Loads all saved dictionary entries from disk
|
void |
save(String path,
String prefix,
int threshold)
Saves all dictionary entries that appeared > threshold times Note: feature
indices are changed to contiguous values starting at 0.
|
void |
setMode(boolean mode) |
int |
size() |
public static final String NIL_VALUE
public StringDictionary(String name)
public void setMode(boolean mode)
public int size()
public int get(String s)
public StringDictionary.IndexAndCount getIndexAndCount(String s)
public int get(String s, boolean shouldThrow)
public String get(int idx)
public int getCount(int idx)
public void save(String path, String prefix, int threshold) throws IOException
IOException
public void clear()
public void load(String path, String prefix) throws IOException
IOException