Search in sources :

Example 1 with EntailmentResult

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);
}
Also used : MetricResponse(edu.illinois.cs.cogcomp.sim.MetricResponse) EntailmentResult(edu.illinois.cs.cogcomp.mrcs.dataStructures.EntailmentResult)

Example 2 with EntailmentResult

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);
}
Also used : MetricResponse(edu.illinois.cs.cogcomp.sim.MetricResponse) EntailmentResult(edu.illinois.cs.cogcomp.mrcs.dataStructures.EntailmentResult)

Example 3 with EntailmentResult

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);
}
Also used : SimConfigurator(edu.illinois.cs.cogcomp.config.SimConfigurator) EntailmentResult(edu.illinois.cs.cogcomp.mrcs.dataStructures.EntailmentResult) IllinoisTokenizer(edu.illinois.cs.cogcomp.nlp.tokenizer.IllinoisTokenizer) WordListFilter(edu.illinois.cs.cogcomp.llm.align.WordListFilter) ResourceManager(edu.illinois.cs.cogcomp.core.utilities.configuration.ResourceManager)

Aggregations

EntailmentResult (edu.illinois.cs.cogcomp.mrcs.dataStructures.EntailmentResult)3 MetricResponse (edu.illinois.cs.cogcomp.sim.MetricResponse)2 SimConfigurator (edu.illinois.cs.cogcomp.config.SimConfigurator)1 ResourceManager (edu.illinois.cs.cogcomp.core.utilities.configuration.ResourceManager)1 WordListFilter (edu.illinois.cs.cogcomp.llm.align.WordListFilter)1 IllinoisTokenizer (edu.illinois.cs.cogcomp.nlp.tokenizer.IllinoisTokenizer)1