
cc.mallet.util.Sequences Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jcore-mallet-2.0.9 Show documentation
Show all versions of jcore-mallet-2.0.9 Show documentation
MALLET is a Java-based package for statistical natural language processing, document classification, clustering, topic modeling, information extraction, and other machine learning applications to text.
The newest version!
package cc.mallet.util;
import cc.mallet.types.Sequence;
/** Utility methods for cc.mallet.types.Sequence and similar classes. */
public class Sequences {
public static double elementwiseAccuracy (Sequence truth, Sequence predicted) {
int accuracy = 0;
assert (truth.size() == predicted.size());
for (int i = 0; i < predicted.size(); i++) {
//logger.fine("tokenAccuracy: ref: "+referenceOutput.get(i)+" viterbi: "+output.get(i));
if (truth.get(i).toString().equals (predicted.get(i).toString())) {
accuracy++;
}
}
return ((double)accuracy)/predicted.size();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy