/** * */ package mpqa_seq_reranker; import java.util.*; import java.util.Iterator; import se.lth.cs.nlp.nlputils.annotations.*; public class SentenceData { public String text; public ArrayList goldSpans = new ArrayList(); public ArrayList candidates = new ArrayList(); public SynSemParse parse; public void simplifyStats() { for(Iterator it = goldSpans.iterator(); it.hasNext(); ) { Span s = it.next(); if(s.label.equals("os")) it.remove(); else s.label = "OP"; } AnnotationLayer gl = new AnnotationLayer(); gl.spans = goldSpans; for(Candidate c: candidates) { for(Iterator it = c.spans.iterator(); it.hasNext(); ) { Span s = it.next(); if(s.label.equals("os")) it.remove(); else s.label = "OP"; } AnnotationLayer cl = new AnnotationLayer(); cl.spans = c.spans; double[] cmp = gl.compareApprox(cl); c.stats.nCorrect = cmp[3]; c.stats.nGuesses = cmp[4]; c.stats.nInGold = cmp[5]; c.stats.propGuessed = cmp[6]; c.stats.propFound = cmp[7]; c.stats.nOverlap = cmp[8]; } } public void simplifyStats(HashMap classes) { for(Iterator it = goldSpans.iterator(); it.hasNext(); ) { Span s = it.next(); String cl = classes.get(s.label); if(cl == null) it.remove(); else s.label = cl; } AnnotationLayer gl = new AnnotationLayer(); gl.spans = goldSpans; for(Candidate c: candidates) { for(Iterator it = c.spans.iterator(); it.hasNext(); ) { Span s = it.next(); String cl = classes.get(s.label); if(cl == null) it.remove(); else s.label = cl; } AnnotationLayer cl = new AnnotationLayer(); cl.spans = c.spans; double[] cmp = gl.compareApprox(cl); c.stats.nCorrect = cmp[3]; c.stats.nGuesses = cmp[4]; c.stats.nInGold = cmp[5]; c.stats.propGuessed = cmp[6]; c.stats.propFound = cmp[7]; c.stats.nOverlap = cmp[8]; } } }