use of edu.illinois.cs.cogcomp.mrcs.dataStructures.EntailmentResult 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.mrcs.dataStructures.EntailmentResult 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.mrcs.dataStructures.EntailmentResult in project cogcomp-nlp by CogComp.
the class LlmStringComparator method initialize.
private void initialize(ResourceManager rm_, Comparator<String, EntailmentResult> comparator) throws IOException {
ResourceManager fullRm = new SimConfigurator().getConfig(rm_);
double threshold = fullRm.getDouble(SimConfigurator.LLM_ENTAILMENT_THRESHOLD.key);
tokenizer = new IllinoisTokenizer();
this.comparator = comparator;
filter = new WordListFilter(fullRm);
neAligner = new Aligner<String, EntailmentResult>(new NEComparator(), filter);
aligner = new Aligner<String, EntailmentResult>(comparator, filter);
scorer = new GreedyAlignmentScorer<String>(threshold);
}
Aggregations