edu.stanford.nlp.stats.AbstractCounter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stanford-parser Show documentation
Show all versions of stanford-parser Show documentation
Stanford Parser processes raw text in English, Chinese, German, Arabic, and French, and extracts constituency parse trees.
package edu.stanford.nlp.stats;
import edu.stanford.nlp.math.SloppyMath;
/**
* Default implementations of all the convenience methods provided by
* {@link Counter}.
*
* @author dramage
*/
public abstract class AbstractCounter implements Counter {
public double logIncrementCount(E key, double amount) {
double count = SloppyMath.logAdd(getCount(key), amount);
setCount(key, count);
return getCount(key);
}
public double incrementCount(E key, double amount) {
double count = getCount(key) + amount;
setCount(key, count);
// get the value just to make sure it agrees with what is in the counter
// (in case it's a float or int)
return getCount(key);
}
public double incrementCount(E key) {
return incrementCount(key, 1.0);
}
public double decrementCount(E key, double amount) {
return incrementCount(key, -amount);
}
public double decrementCount(E key) {
return incrementCount(key, -1.0);
}
/** {@inheritDoc} */
public void addAll(Counter counter) {
Counters.addInPlace(this, counter);
}
}