@Override
public void computeSimilarity(ParaphraseExample ex, Params params) {
ex.ensureAnnotated();
FeatureVector fv = new FeatureVector();
double precision = MathUtils.coverage(ex.sourceInfo.tokens, ex.targetInfo.tokens);
double recall = MathUtils.coverage(ex.targetInfo.tokens, ex.sourceInfo.tokens);
double f1 = (precision+recall<=0d)? 0d :
(2 * precision * recall) / (precision+recall);
double lemmaPrecision = MathUtils.coverage(ex.sourceInfo.lemmaTokens, ex.targetInfo.lemmaTokens);
double lemmaRecall = MathUtils.coverage(ex.targetInfo.lemmaTokens, ex.sourceInfo.lemmaTokens);
addIfBetweenZeroAndOne(fv, "Wan", "precision", precision);
addIfBetweenZeroAndOne(fv, "Wan", "recall", recall);
addIfBetweenZeroAndOne(fv, "Wan", "f1", f1);
addIfBetweenZeroAndOne(fv, "Wan", "lemmaPrecision", lemmaPrecision);
addIfBetweenZeroAndOne(fv, "Wan", "lemmaRecall", lemmaRecall);
fv.add("Wan", "lengthDiff", ex.sourceInfo.numTokens()-ex.targetInfo.numTokens());
fv.add("Wan", "AbsLengthDiff", Math.abs(ex.sourceInfo.numTokens()-ex.targetInfo.numTokens()));
int editDistance = ParaphraseUtils.editDistance(ex.sourceInfo.tokens, ex.targetInfo.tokens);
int lemmaEditDistance = ParaphraseUtils.editDistance(ex.sourceInfo.lemmaTokens, ex.targetInfo.lemmaTokens);
fv.add("Wan", "editDistance", editDistance);
fv.add("Wan", "lemmaEditDistance", lemmaEditDistance);
double precisionBleu = MathUtils.bleu(ex.sourceInfo.tokens, ex.targetInfo.tokens);
double recallBleu = MathUtils.bleu(ex.targetInfo.tokens, ex.sourceInfo.tokens);
double lemmaPecisionBleu = MathUtils.bleu(ex.sourceInfo.lemmaTokens, ex.targetInfo.lemmaTokens);
double lemmaRecallBleu = MathUtils.bleu(ex.targetInfo.lemmaTokens, ex.sourceInfo.lemmaTokens);
addIfBetweenZeroAndOne(fv, "Wan", "precisionBlue", precisionBleu);