|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectkylm.util.SymbolSet
public class SymbolSet
A class that holds a mapping from vocabulary to integers
Field Summary | |
---|---|
java.util.HashMap<java.lang.String,java.lang.Integer> |
ids
|
java.util.Vector<java.lang.String> |
syms
|
Constructor Summary | |
---|---|
SymbolSet()
Create a new symbol set |
Method Summary | |
---|---|
void |
addAlias(java.lang.String sym,
int id)
Add an alias to the vocabulary. |
int |
addSymbol(java.lang.String sym)
|
int |
addSymbol(java.lang.String sym,
boolean overrideAlias)
Add a symbol to the vocabulary. |
void |
addSymbols(java.lang.String[] symbols)
Add multiple symbols to the vocabulary |
boolean |
equals(java.lang.Object obj)
|
java.lang.Integer |
getId(java.lang.String s)
Get the ID associated with a symbol |
int |
getSize()
Get the size of the symbol set. |
java.lang.String |
getSymbol(int id)
Get the symbol associated with the ID. |
java.lang.String[] |
getSymbols()
Return every symbol in the symbol set. |
static SymbolSet |
readFromFile(java.lang.String fileName)
Read a symbol set from a file The format can either be one symbol per line, or one symbol followed by its ID per line, in which case the lines must be in ascending order starting with symbol number one |
void |
writeToFile(java.lang.String string,
boolean writeNumbers)
|
Methods inherited from class java.lang.Object |
---|
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public java.util.HashMap<java.lang.String,java.lang.Integer> ids
public java.util.Vector<java.lang.String> syms
Constructor Detail |
---|
public SymbolSet()
Method Detail |
---|
public int addSymbol(java.lang.String sym, boolean overrideAlias)
sym
- The symbol to be added.overrideAlias
- Whether or not to delete aliases.
public int addSymbol(java.lang.String sym)
public void addSymbols(java.lang.String[] symbols)
symbols
- The symbols to addpublic void addAlias(java.lang.String sym, int id)
sym
- The symbol of the alias.id
- The id number that the alias should point to.public java.lang.String getSymbol(int id)
id
- The ID to search for.
public int getSize()
public java.lang.String[] getSymbols()
public java.lang.Integer getId(java.lang.String s)
s
- The symbol
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public static SymbolSet readFromFile(java.lang.String fileName) throws java.io.IOException
fileName
- The name of the file to read from
java.io.IOException
- If there is a problem with the input or the file is
not in the proper formatpublic void writeToFile(java.lang.String string, boolean writeNumbers) throws java.io.IOException
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |