int trueNegative = 0;
int allClassifiedPos = 0;
int allClassifiedNeg = 0;
Sentiment currentLabel;
int numNotClassified = 0;
SentenceFeaturePair tempEx;
ArrayList<String> currentFeatures = new ArrayList<String>();
for (int i = 0; i < numExs; i++) {
tempEx = (SentenceFeaturePair) positiveExamples.get(i);
currentFeatures.clear();
currentFeatures.add(tempEx.getTheFeature().Name);
currentLabel = classifier.classifyText(tempEx.getDataBody(), currentFeatures).get(tempEx.getTheFeature().Name);
if (currentLabel == Sentiment.Positive) {
truePositive++;
allClassifiedPos++;
} else if (currentLabel == Sentiment.Negative) {
allClassifiedNeg++;
wrongPos.add(tempEx.getTheFeature().Name + "---" + tempEx.getDataBody());
} else {
numNotClassified++;
notClassified.add(tempEx.getTheFeature().Name + "---" + tempEx.getDataBody());
}
}
for (int i = 0; i < numExs; i++) {
tempEx = (SentenceFeaturePair) negativeExamples.get(i);
currentFeatures.clear();
currentFeatures.add(tempEx.getTheFeature().Name);
currentLabel = classifier.classifyText(tempEx.getDataBody(), currentFeatures).get(tempEx.getTheFeature().Name);
if (currentLabel == Sentiment.Negative) {
trueNegative++;
allClassifiedNeg++;
} else if (currentLabel == Sentiment.Positive) {
allClassifiedPos++;
wrongNeg.add(tempEx.getTheFeature().Name + "---" + tempEx.getDataBody());
} else {
numNotClassified++;
notClassified.add(tempEx.getTheFeature().Name + "---" + tempEx.getDataBody());
}
}
EvaluationMeasures evMeasures = new EvaluationMeasures();
evMeasures.setMeasures(allClassifiedPos, allClassifiedNeg, truePositive, trueNegative);