public abstract class JensenShannonDistance extends AbstractTokenizedStringDistance
tokenizer| Constructor and Description |
|---|
JensenShannonDistance() |
JensenShannonDistance(Tokenizer tokenizer) |
| Modifier and Type | Method and Description |
|---|---|
protected double |
backgroundProb(Token tok)
Probability of token in the background language model
|
String |
explainScore(StringWrapper s,
StringWrapper t)
This method needs to be implemented by subclasses.
|
StringWrapper |
prepare(String s)
Preprocess a string by finding tokens and giving them weights W
such that W is the smoothed probability of the token appearing
in the document.
|
double |
score(StringWrapper s,
StringWrapper t)
Jensen-Shannon distance between distributions.
|
protected abstract double |
smoothedProbability(Token tok,
double freq,
double totalWeight)
Smoothed probability of the token with frequency freq in a bag with the given totalWeight
|
void |
train(StringWrapperIterator i)
Accumulate statistics on how often each token occurs.
|
asBagOfTokens, prepare, setStringWrapperPooladdExample, doMain, explainScore, getDistance, hasNextQuery, nextQuery, prepare, score, setDistanceInstancePoolpublic JensenShannonDistance(Tokenizer tokenizer)
public JensenShannonDistance()
public final void train(StringWrapperIterator i)
train in class AbstractTokenizedStringDistancepublic final StringWrapper prepare(String s)
prepare in interface StringDistanceprepare in class AbstractStringDistanceprotected abstract double smoothedProbability(Token tok, double freq, double totalWeight)
protected double backgroundProb(Token tok)
public final double score(StringWrapper s, StringWrapper t)
score in interface StringDistancescore in class AbstractStringDistancepublic final String explainScore(StringWrapper s, StringWrapper t)
AbstractStringDistanceexplainScore in interface StringDistanceexplainScore in class AbstractStringDistanceCopyright © 2016. All rights reserved.