Constructor and Description |
---|
NGramMap()
Default constructor
|
NGramMap(int n)
Create an n-gram to frequency map.
|
NGramMap(int n,
Map<NGram,Integer> map)
Create an n-gram to frequency map.
|
NGramMap(int n,
Map<NGram,Integer> map,
int textSize)
Create an n-gram to frequency map.
|
NGramMap(NGramMap map)
Copy an n-gram to frequency map.
|
Modifier and Type | Method and Description |
---|---|
int |
calcOrigTextSize()
Calculates the total number of elements in the original text based on the current
contents of the map.
|
boolean |
decreaseFreq(NGram nGram)
Removes an n-gram from the map or decrease the frequency if the absolute
frequency is greater than one.
|
boolean |
equals(Object obj) |
void |
filterByThreshold(int min,
int max)
Filters this n-gram map of all frequencies between min
and max inclusively.
|
void |
filterByTotal(int total)
Filters this n-gram map of all but the top frequencies.
|
static TokenDecoder |
getDecoder() |
static TokenEncoder |
getEncoder() |
int |
getFrequency(NGram ngram)
Get the absolute frequency of an NGram in the map.
|
List<Integer> |
getFrequencyList()
Get an ordered list of the absolute frequencies contained in the map.
|
Map<NGram,Integer> |
getMap()
Get a copy of the map that backs this object.
|
int |
getN()
Get the degree of the n-grams in this map.
|
List<NGram> |
getNGramList()
Get an ordered list of the n-grams contained in the map.
|
int |
getOrigTextSize()
Get the total number of elements in the original text.
|
double |
getProbability(NGram ngram)
Get the relative frequency of an n-gram in the map.
|
List<Double> |
getProbabilityList()
Get an ordered list of the relative frequencies contained in the map.
|
int |
hashCode() |
boolean |
increaseFreq(NGram nGram)
Adds an n-gram to the map or increases the frequency if it is already present.
|
Iterator<Map.Entry<NGram,Integer>> |
iterator()
Get an iterator over the entries in the map.
|
int |
removeNGram(NGram nGram)
Removes an n-gram from the map.
|
void |
setOrigTextSize(int origTextSize)
Set the total number of elements in the original text.
|
String |
toString() |
public NGramMap()
public NGramMap(int n)
n
- the degree of the NGrams in the mappublic NGramMap(int n, Map<NGram,Integer> map)
n
- the degree of the NGrams in the mapmap
- the mappings to usepublic NGramMap(int n, Map<NGram,Integer> map, int textSize)
n
- the degree of the NGrams in the mapmap
- the mappings to usetextSize
- the number of elements in the original textpublic NGramMap(NGramMap map)
map
- the n-gram map to copypublic int getN()
public int getOrigTextSize()
public void setOrigTextSize(int origTextSize)
origTextSize
- the total number of words in the original textpublic List<NGram> getNGramList()
public List<Integer> getFrequencyList()
public List<Double> getProbabilityList()
public Map<NGram,Integer> getMap()
public int calcOrigTextSize()
public Iterator<Map.Entry<NGram,Integer>> iterator()
public int getFrequency(NGram ngram)
ngram
- the n-gram to get the frequency ofpublic double getProbability(NGram ngram)
ngram
- the n-gram to get the frequency ofpublic boolean increaseFreq(NGram nGram)
nGram
- element to increase the frequency of in the mappublic boolean decreaseFreq(NGram nGram)
nGram
- element to decrease the frequency of in the mappublic int removeNGram(NGram nGram)
nGram
- element to remove from the mappublic void filterByThreshold(int min, int max)
min
- the smallest frequency to keepmax
- the largest frequency to keeppublic void filterByTotal(int total)
total
- number of top frequencies to keeppublic static TokenEncoder getEncoder()
public static TokenDecoder getDecoder()
Copyright © 2021 Actian Corporation. All rights reserved.