public class DefaultTermCounts extends AbstractCloneableSerializable implements TermCounts
TermCounts
interface.Modifier and Type | Field and Description |
---|---|
protected java.util.HashMap<Term,java.lang.Integer> |
termToCountMap
The mapping of terms to their respective counts.
|
protected int |
totalCount
The total of all counts.
|
Constructor and Description |
---|
DefaultTermCounts()
Creates a new, empty
DefaultTermCounts . |
Modifier and Type | Method and Description |
---|---|
void |
add(Termable term)
Increments the count for a given term.
|
void |
add(Term term,
int count)
Adds the given amount for the given term.
|
void |
addAll(java.lang.Iterable<? extends Termable> terms)
Adds all of the given terms to the counters; one for each term
occurrence.
|
int |
getCount(Term term)
Get the count for a given term.
|
java.util.Set<Term> |
getTerms()
Gets the set of all terms the counts are over.
|
protected java.util.HashMap<Term,java.lang.Integer> |
getTermToCountMap()
Gets the mapping of terms to their respective counts.
|
int |
getTotalCount()
Gets the total count of all terms.
|
protected void |
setTermToCountMap(java.util.HashMap<Term,java.lang.Integer> termToCountMap)
Gets the mapping of terms to their respective counts.
|
protected void |
setTotalCount(int totalCount)
Sets the total count.
|
clone
protected int totalCount
protected java.util.HashMap<Term,java.lang.Integer> termToCountMap
public DefaultTermCounts()
DefaultTermCounts
.public void add(Termable term)
term
- The term to add.public void add(Term term, int count)
term
- The term to add.count
- The amount to add to the count of the term. Must be positive.public void addAll(java.lang.Iterable<? extends Termable> terms)
terms
- The terms to add.public int getCount(Term term)
TermCounts
getCount
in interface TermCounts
term
- The term to get the counts for.public java.util.Set<Term> getTerms()
TermCounts
getTerms
in interface TermCounts
public int getTotalCount()
TermCounts
getTotalCount
in interface TermCounts
protected void setTotalCount(int totalCount)
totalCount
- The total count.protected java.util.HashMap<Term,java.lang.Integer> getTermToCountMap()
protected void setTermToCountMap(java.util.HashMap<Term,java.lang.Integer> termToCountMap)
termToCountMap
- The mapping of terms to their respective counts.