|
Parsing Engine | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractMap<K,Object>
danbikel.util.AbstractMapToPrimitive
danbikel.parser.FileBackedTrainerEventMap
public class FileBackedTrainerEventMap
Presents an immutable map of a type of TrainerEvent objects to
observed counts, backed by a file of the form output by
Trainer.writeStats(java.io.File). The contract of the Map
interface may be violated if the underlying file does not contain
a collection of unique TrainerEvent objects; however, this
contract violation may not be a problem for many kinds of operations,
such as those that rely simply on the ability to iterate over all
observed events. One such operation is the additive derivation of
counts as implemented by the method
Model.deriveCounts(CountsTable,Filter,double,FlexibleMap).
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class danbikel.util.AbstractMapToPrimitive |
|---|
AbstractMapToPrimitive.Entry<K> |
| Nested classes/interfaces inherited from class java.util.AbstractMap |
|---|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V> |
| Nested classes/interfaces inherited from interface danbikel.util.MapToPrimitive |
|---|
MapToPrimitive.Entry<K> |
| Constructor Summary | |
|---|---|
FileBackedTrainerEventMap(Symbol type,
File file)
Constructs a new file-backed TrainerEvent map for events of the
specified type and using the specified file. |
|
FileBackedTrainerEventMap(Symbol type,
String filename)
Constructs a new file-backed TrainerEvent map for events of the
specified type and using the specified file. |
|
| Method Summary | |
|---|---|
void |
add(Object key)
Throws an UnsupportedOperationException, as this is an
unmodifiable map. |
void |
addAll(CountsTable other)
Throws an UnsupportedOperationException, as this is an
unmodifiable map. |
double |
count(Object key)
Returns the count of the specified key, or 0 if this
counts table does not contain a count for the specified key. |
double |
count(Object key,
int hashCode)
Returns the count of the specified key with the specified hash code, or 0 if this counts table does not contain a count for the
specified key. |
Set |
entrySet()
Returns an entry set view of the map entries. |
MapToPrimitive.Entry |
getEntry(Object key)
Uses an Ο(n) algorithm to retrieve the map entry for the specified key. |
MapToPrimitive.Entry |
getEntry(Object key,
int hashCode)
Simply invokes getEntry(key), returning the map entry for the
specified key. |
MapToPrimitive.Entry |
getEntryMRU(Object key)
Throws an UnsupportedOperationException because this is an
unmodifiable map. |
MapToPrimitive.Entry |
getEntryMRU(Object key,
int hashCode)
Throws an UnsupportedOperationException because this is an
unmodifiable map. |
void |
output(String filename,
Writer writer)
Throws an UnsupportedOperationException, because isn't it silly
to try to copy an already file-backed map to a file? |
void |
putAll(CountsTable other)
Throws an UnsupportedOperationException, as this is an
unmodifiable map. |
void |
removeItemsBelow(double threshold)
Throws an UnsupportedOperationException, as this is an
unmodifiable map. |
void |
removeRandom(int bucketIndex)
Throws an UnsupportedOperationException because this is an
unmodifiable map. |
| Methods inherited from class danbikel.util.AbstractMapToPrimitive |
|---|
add, add, add, add, add, add, add, add, add, add, add, add, put, put, put, put, put, put, put, put, put, put, put, put, put, put, removeRandom, toString |
| Methods inherited from class java.util.AbstractMap |
|---|
clear, clone, containsKey, containsValue, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface danbikel.util.MapToPrimitive |
|---|
add, add, add, add, add, add, add, add, add, add, add, add, put, put, put, put, put, put, put, put, put, put, put, put, put, put, removeRandom |
| Methods inherited from interface java.util.Map |
|---|
clear, containsKey, containsValue, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
| Constructor Detail |
|---|
public FileBackedTrainerEventMap(Symbol type,
String filename)
throws FileNotFoundException
TrainerEvent map for events of the
specified type and using the specified file.
type - the type of TrainerEvent objects in the specified
file over which to iterate; this argument must be one of
the following values:
Trainer.nonterminalEventSym
Trainer.headEventSym
Trainer.modEventSym
Trainer.gapEventSym
Trainer.posMapSym
Trainer.vocabSym
Trainer.wordFeatureSym
Trainer.prunedPretermSym
Trainer.prunedPuncSym
filename - the file containing S-expressions representing TrainerEvent objects, where the S-expressions are of the
form output by Trainer.writeStats(java.io.File)
FileNotFoundException - if the specified file does not exist
public FileBackedTrainerEventMap(Symbol type,
File file)
throws FileNotFoundException
TrainerEvent map for events of the
specified type and using the specified file.
type - the type of TrainerEvent objects in the specified
file over which to iterate; this argument must be one of
the following values:
Trainer.nonterminalEventSym
Trainer.headEventSym
Trainer.modEventSym
Trainer.gapEventSym
Trainer.posMapSym
Trainer.vocabSym
Trainer.wordFeatureSym
Trainer.prunedPretermSym
Trainer.prunedPuncSym
file - the file containing S-expressions representing TrainerEvent objects, where the S-expressions are of the
form output by Trainer.writeStats(java.io.File)
FileNotFoundException - if the specified file does not exist| Method Detail |
|---|
public void addAll(CountsTable other)
UnsupportedOperationException, as this is an
unmodifiable map.
addAll in interface CountsTableother - ignoredpublic void putAll(CountsTable other)
UnsupportedOperationException, as this is an
unmodifiable map.
putAll in interface CountsTableother - ignoredpublic void add(Object key)
UnsupportedOperationException, as this is an
unmodifiable map.
add in interface CountsTablekey - ignoredpublic double count(Object key)
CountsTable0 if this
counts table does not contain a count for the specified key.
count in interface CountsTablekey - the key whose count is to be gotten
0 if this
counts table does not contain a count for the specified key
public double count(Object key,
int hashCode)
CountsTable0 if this counts table does not contain a count for the
specified key.
count in interface CountsTablekey - the key whose count is to be gottenhashCode - the hash code of the specified key
0 if this counts table does not contain a count for the
specified keypublic void removeItemsBelow(double threshold)
UnsupportedOperationException, as this is an
unmodifiable map.
removeItemsBelow in interface CountsTablethreshold - ignored
public void output(String filename,
Writer writer)
UnsupportedOperationException, because isn't it silly
to try to copy an already file-backed map to a file?
output in interface CountsTablefilename - the name of the events contained in this CountsTable
to output as the first symbol in the three-element listwriter - the writer to which to output the elements of this
counts table as three-element S-expression listspublic Set entrySet()
entrySet in interface MapentrySet in class AbstractMappublic void removeRandom(int bucketIndex)
UnsupportedOperationException because this is an
unmodifiable map.
removeRandom in interface MapToPrimitiveremoveRandom in class AbstractMapToPrimitivebucketIndex - ignoredpublic MapToPrimitive.Entry getEntry(Object key)
getEntry in interface MapToPrimitivegetEntry in class AbstractMapToPrimitivekey - the key for which to retrieve a map entry
public MapToPrimitive.Entry getEntry(Object key,
int hashCode)
getEntry(key), returning the map entry for the
specified key.
getEntry in interface MapToPrimitivekey - the key for which to get a map entryhashCode - ignored
getEntry(Object)public MapToPrimitive.Entry getEntryMRU(Object key)
UnsupportedOperationException because this is an
unmodifiable map.
getEntryMRU in interface MapToPrimitivegetEntryMRU in class AbstractMapToPrimitivekey - ignored
public MapToPrimitive.Entry getEntryMRU(Object key,
int hashCode)
UnsupportedOperationException because this is an
unmodifiable map.
getEntryMRU in interface MapToPrimitivekey - ignored
|
Parsing Engine | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||