public class DisplayWorld extends TextWorld
Modifier and Type | Class and Description |
---|---|
class |
DisplayWorld.StringDataPoint
Associates a datapoint object (basically a double vector that can be
processed by the ntree) with a string.
|
TextWorld.TextItem
tokenDictionary
Constructor and Description |
---|
DisplayWorld()
Constructs an instance of TextWorld.
|
Modifier and Type | Method and Description |
---|---|
void |
addTextIfAboveThreshold(double value,
java.lang.String string)
Add the provided text, if the provided value is above threshold.
|
void |
addVectorTokenPair(java.lang.String token,
double[] vec)
Add an entry to the vector-token dictionary.
|
void |
displayClosestWord(double[] key)
Display the string associated with the closest matching vector in the
dictionary.
|
java.lang.String |
getClosestWord(double[] key)
Finds the closest vector in terms of Euclidean distance, then returns the
String associated with it.
|
double |
getDisplayThreshold() |
NTree |
getVectorToTokenDict() |
(package private) static com.thoughtworks.xstream.XStream |
getXStream()
Returns a properly initialized xstream object.
|
void |
loadVectorToTokenDict(java.lang.String[][] tableData)
Loads a new vector to token dictionary stored as a matrix of Strings.
|
void |
postOpenInit()
Initializes Dataset from persistent data.
|
void |
preSaveInit()
Initializes persistent data.
|
protected java.lang.Object |
readResolve()
Standard method call made to objects after they are deserialized.
|
void |
setDisplayThreshold(double displayThreshold) |
void |
update()
Advance the position in the text, and update the current item.
|
addListener, addText, addWordToTokenDictionary, fireCurrentItemChanged, fireDictionaryChangedEvent, firePositionChangedEvent, firePrefsChangedEvent, fireTextChangedEvent, getCurrentItem, getHighlightColor, getLastPosition, getPosition, getText, getTokenDictionary, loadTokenDictionary, previewNextChar, removeListener, setCurrentItem, setHighlightColor, setPosition, setPosition, setText, setText
public void update()
TextWorld
public java.lang.String getClosestWord(double[] key)
displayClosestWord(double[])
so it can be used in scripts.key
- the vector to check.public void displayClosestWord(double[] key)
getClosestWord(double[])
.key
- the vector to use to search the dictionary.public void addTextIfAboveThreshold(double value, java.lang.String string)
value
- value to check against thresholdstring
- text to addstatic com.thoughtworks.xstream.XStream getXStream()
protected java.lang.Object readResolve()
readResolve
in class TextWorld
public void preSaveInit()
public void postOpenInit()
public double getDisplayThreshold()
public void setDisplayThreshold(double displayThreshold)
displayThreshold
- the displayThreshold to setpublic NTree getVectorToTokenDict()
public void loadVectorToTokenDict(java.lang.String[][] tableData)
tableData
- the string matrix encoding the dictionary.public void addVectorTokenPair(java.lang.String token, double[] vec)
token
- the String to addvec
- the vector