use of edu.illinois.cs.cogcomp.sim.MetricResponse in project cogcomp-nlp by CogComp.
the class WordComparator method compare.
@Override
public EntailmentResult compare(String specific_, String general_) {
String genTok = StringCleanup.normalizeToLatin1(general_);
String specTok = StringCleanup.normalizeToLatin1(specific_);
double score = 0.0;
String reason = "default reason";
String source = WordComparator.class.getSimpleName();
boolean isEntailed = false;
boolean isPositivePolarity = true;
if (specTok.equalsIgnoreCase(genTok)) {
score = 1.0;
reason = "Identity";
} else {
MetricResponse result = wordSim.compare(specific_, general_);
score = result.score;
reason = result.reason;
isEntailed = (Math.abs(score) > entailmentThreshold);
isPositivePolarity = (score >= 0);
if (computeSimpleScore) {
if (isEntailed) {
score = 1.0;
}
}
}
return new EntailmentResult(source, (float) score, reason, isEntailed, isPositivePolarity, defaultUpwardMonotone, null);
}
use of edu.illinois.cs.cogcomp.sim.MetricResponse in project cogcomp-nlp by CogComp.
the class NEComparator method compare.
@Override
public EntailmentResult compare(String specific_, String general_) throws Exception {
String genTok = StringCleanup.normalizeToLatin1(general_);
String specTok = StringCleanup.normalizeToLatin1(specific_);
double score = 0.0;
String reason = "default reason";
String source = WordComparator.class.getSimpleName();
boolean isEntailed = false;
boolean isPositivePolarity = true;
if (specTok.equalsIgnoreCase(genTok)) {
score = 1.0;
reason = "Identity";
} else {
MetricResponse result = NEComparator.compare(specific_, general_);
score = result.score;
reason = result.reason;
isEntailed = (Math.abs(score) > 0.5);
isPositivePolarity = (score >= 0);
}
return new EntailmentResult(source, (float) score, reason, isEntailed, isPositivePolarity, true, null);
}
use of edu.illinois.cs.cogcomp.sim.MetricResponse in project cogcomp-nlp by CogComp.
the class EntityComparisonTest method testEntityComparison.
@Test
public void testEntityComparison() {
Metric ec = new NESim();
String hitchA = "Bill C. Hitchcock";
String hitchB = "William Hitchcock";
String hitchC = "Mrs. Hitchcock";
String hitchD = "Arthur Hitchcock";
String hitchE = "Bill F. Hitchcock";
MetricResponse result = ec.compare(hitchA, hitchB);
assertEquals(result.score, 1.0, 0.01);
/**
* this test FAILS: no gender test
*/
result = ec.compare(hitchB, hitchC);
// assertTrue(Double.parseDouble(result.get(EntityComparison.SCORE)) <
// 0.5);
result = ec.compare(hitchB, hitchD);
assertTrue(result.score < 0.6);
result = ec.compare(hitchA, hitchE);
// Another test that fails. Critical local difference.
// assertTrue( Double.parseDouble( result.get( EntityComparison.SCORE )
// ) < 0.6 );
}
use of edu.illinois.cs.cogcomp.sim.MetricResponse in project cogcomp-nlp by CogComp.
the class WordSimTest method testParagram.
@Test
public void testParagram() throws Exception {
WordSim ws = new WordSim(rm_, "paragram");
MetricResponse m1 = ws.compare("word", "sentence", "paragram");
MetricResponse m2 = ws.compare("word", "wife", "paragram");
assertTrue(m1.score > m2.score);
}
use of edu.illinois.cs.cogcomp.sim.MetricResponse in project cogcomp-nlp by CogComp.
the class WordSimTest method testWordNet.
@Test
public void testWordNet() {
WordSim ws = new WordSim(rm_, "wordnet");
MetricResponse m1 = ws.compare("word", "sentence", "wordnet");
MetricResponse m2 = ws.compare("word", "wife", "wordnet");
assertTrue(m1.score > m2.score);
}
Aggregations