java.lang.Object
com.pervasive.datarush.analytics.text.NGramMap
com.pervasive.datarush.analytics.text.WordMap
Implementation of a word frequency model.
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionWordMap()Default constructor of an empty word map.Convert a valid NGramMap into a word map.Copy a word to frequency map.Create a word to frequency map.Create a word to frequency map. -
Method Summary
Modifier and TypeMethodDescriptionbooleandecreaseFreq(String word) Removes a word from the map or decrease the frequency if the absolute frequency is greater than one.static TokenDecoderstatic TokenEncoderintgetFrequency(String word) Get the absolute frequency of a word in the map.doublegetProbability(String word) Get the relative frequency of a word in the map.Get a copy of the map that backs this object.Get an ordered list of the words contained in the map.booleanincreaseFreq(String word) Adds a word to the map or increases the frequency if it is already present.intremoveWord(String word) Removes a word from the map.toString()Methods inherited from class com.pervasive.datarush.analytics.text.NGramMap
calcOrigTextSize, decreaseFreq, equals, filterByThreshold, filterByTotal, getFrequency, getFrequencyList, getMap, getN, getNGramList, getOrigTextSize, getProbability, getProbabilityList, hashCode, increaseFreq, iterator, removeNGram, setOrigTextSize
-
Constructor Details
-
WordMap
public WordMap()Default constructor of an empty word map. -
WordMap
Create a word to frequency map.- Parameters:
map- the mappings to use
-
WordMap
Create a word to frequency map.- Parameters:
map- the mappings to usetextSize- the number of elements in the original text
-
WordMap
Copy a word to frequency map.- Parameters:
map- the word map to copy
-
WordMap
Convert a valid NGramMap into a word map. A valid map has an N of one. If the NGramMap is invalid the WordMap will remain empty.- Parameters:
map- the n-gram map to convert
-
-
Method Details
-
getWordList
Get an ordered list of the words contained in the map.- Returns:
- the list of words
-
getFrequency
Get the absolute frequency of a word in the map.- Parameters:
word- the word to get the frequency of- Returns:
- the absolute frequency of the word
-
getProbability
Get the relative frequency of a word in the map. If OrigTextSize has not been set will calculate based on the current map.- Parameters:
word- the word to get the frequency of- Returns:
- the relative frequency of the word
-
increaseFreq
Adds a word to the map or increases the frequency if it is already present.- Parameters:
word- element to increase the frequency of in the map- Returns:
- true if word is valid and could be incremented
-
decreaseFreq
Removes a word from the map or decrease the frequency if the absolute frequency is greater than one.- Parameters:
word- element to decrease the frequency of in the map- Returns:
- true if word is valid and could be decremented
-
removeWord
Removes a word from the map.- Parameters:
word- element to remove from the map- Returns:
- the frequency previously associated with the word or null
-
getStringMap
Get a copy of the map that backs this object.- Returns:
- map of Strings to Integers
-
toString
-
getEncoder
-
getDecoder
-