edu.stanford.nlp.ie.machinereading.common
Class StringDictionary
java.lang.Object
edu.stanford.nlp.ie.machinereading.common.StringDictionary
public class StringDictionary
- extends java.lang.Object
|
Field Summary |
static java.lang.String |
NIL_VALUE
|
|
Method Summary |
void |
clear()
|
java.lang.String |
get(int idx)
Reverse mapping from integer key to string value |
int |
get(java.lang.String s)
|
int |
get(java.lang.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(java.lang.String s)
|
java.util.Set<java.lang.String> |
keys()
|
java.util.Set<java.lang.String> |
keySet()
|
void |
load(java.lang.String path,
java.lang.String prefix)
Loads all saved dictionary entries from disk |
void |
save(java.lang.String path,
java.lang.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()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NIL_VALUE
public static final java.lang.String NIL_VALUE
- See Also:
- Constant Field Values
StringDictionary
public StringDictionary(java.lang.String name)
setMode
public void setMode(boolean mode)
size
public int size()
get
public int get(java.lang.String s)
getIndexAndCount
public StringDictionary.IndexAndCount getIndexAndCount(java.lang.String s)
get
public int get(java.lang.String s,
boolean shouldThrow)
- Fetches the index of this string If mCreate is true, the entry is created
if it does not exist. If mCreate is true, the count of the entry is
incremented for every get If no entry found throws an exception if
shouldThrow == true
get
public java.lang.String get(int idx)
- Reverse mapping from integer key to string value
getCount
public int getCount(int idx)
save
public void save(java.lang.String path,
java.lang.String prefix,
int threshold)
throws java.io.IOException
- Saves all dictionary entries that appeared > threshold times Note: feature
indices are changed to contiguous values starting at 0. This is needed in
order to minimize the memory allocated for the expanded feature vectors
(average perceptron).
- Throws:
java.io.IOException
clear
public void clear()
keySet
public java.util.Set<java.lang.String> keySet()
load
public void load(java.lang.String path,
java.lang.String prefix)
throws java.io.IOException
- Loads all saved dictionary entries from disk
- Throws:
java.io.IOException
keys
public java.util.Set<java.lang.String> keys()
Stanford NLP Group