/** * Test for {@link Span#compareTo(Object)}. */ @Test public void testCompareToLower() { Span a = new Span(100, 1000); Span b = new Span(10, 50); Assert.assertEquals(true, a.compareTo(b) > 0); }
/** * Test for {@link Span#compareTo(Object)}. */ @Test public void testCompareToEqualsDiffType2() { Span a = new Span(30, 1000, "b"); Span b = new Span(30, 1000, "a"); Assert.assertEquals(true, a.compareTo(b) == 1); }
/** * Test for {@link Span#compareTo(Object)}. */ @Test public void testCompareToEqualsNullType2() { Span a = new Span(30, 1000, "b"); Span b = new Span(30, 1000); Assert.assertEquals(true, a.compareTo(b) == -1); }
/** * Test for {@link Span#compareTo(Object)}. */ @Test public void testCompareToEquals() { Span a = new Span(30, 1000); Span b = new Span(30, 1000); Assert.assertEquals(true, a.compareTo(b) == 0); }
/** * Test for {@link Span#compareTo(Object)}. */ @Test public void testCompareToEqualsSameType() { Span a = new Span(30, 1000, "a"); Span b = new Span(30, 1000, "a"); Assert.assertEquals(true, a.compareTo(b) == 0); }
/** * Test for {@link Span#compareTo(Object)}. */ @Test public void testCompareToEqualsDiffType1() { Span a = new Span(30, 1000, "a"); Span b = new Span(30, 1000, "b"); Assert.assertEquals(true, a.compareTo(b) == -1); }
/** * Test for {@link Span#compareTo(Object)}. */ @Test public void testCompareToEqualsNullType1() { Span a = new Span(30, 1000); Span b = new Span(30, 1000, "b"); Assert.assertEquals(true, a.compareTo(b) == 1); }
/** * Test for {@link Span#compareTo(Object)}. */ @Test public void testCompareToHigher() { Span a = new Span(100, 200); Span b = new Span(300, 400); Assert.assertEquals(true, a.compareTo(b) < 0); }
public int compareTo(Mention e) { return span.compareTo(e.span); }
public int compareTo(Mention e) { return span.compareTo(e.span); }
public int compareTo(TextAnnotation a) { int c = span.compareTo(a.span); if (c == 0) { c = Double.compare(prob, a.prob); if (c == 0) { c = type.compareTo(a.type); } } return c; }
public int compareTo(Omission o) { return span.compareTo(o.getSpan()); }
public int compareTo(Omission o) { return span.compareTo(o.getSpan()); }
public int compare(Mistake m1, Mistake m2) { // First we check if they overlap. If they don't we simply use the start position Span a = new Span(m1.getStart(), m1.getEnd()); Span b = new Span(m2.getStart(), m2.getEnd()); if(!a.intersects(b)) { return a.compareTo(b); } // they intersect, so we should sort using the priority. The higher the // number, the higher th priority if(m1.getRulePriority() > m2.getRulePriority()) { return -1; } else if(m1.getRulePriority() < m2.getRulePriority()) { return 1; } else { // equal priority! so we try to use the rule id if(m2.getRuleIdentifier().startsWith("xml:")) { Integer id1 = new Integer(m1.getRuleIdentifier().substring(4)); Integer id2 = new Integer(m2.getRuleIdentifier().substring(4)); return id1.compareTo(id2); } return m1.getRuleIdentifier().compareTo(m2.getRuleIdentifier()); } }
public int compare(Mistake m1, Mistake m2) { // First we check if they overlap. If they don't we simply use the start position Span a = new Span(m1.getStart(), m1.getEnd()); Span b = new Span(m2.getStart(), m2.getEnd()); if(!a.intersects(b)) { return a.compareTo(b); } // they intersect, so we should sort using the priority. The higher the // number, the higher th priority if(m1.getRulePriority() > m2.getRulePriority()) { return -1; } else if(m1.getRulePriority() < m2.getRulePriority()) { return 1; } else { // equal priority! so we try to use the rule id if(m2.getRuleIdentifier().startsWith("xml:")) { Integer id1 = new Integer(m1.getRuleIdentifier().substring(4)); Integer id2 = new Integer(m2.getRuleIdentifier().substring(4)); return id1.compareTo(id2); } return m1.getRuleIdentifier().compareTo(m2.getRuleIdentifier()); } }
public int compareTo(opennlp.tools.coref.mention.Parse p) { if (p == this) { return 0; } if (getSentenceNumber() < p.getSentenceNumber()) { return -1; } else if (getSentenceNumber() > p.getSentenceNumber()) { return 1; } else { if (parse.getSpan().getStart() == p.getSpan().getStart() && parse.getSpan().getEnd() == p.getSpan().getEnd()) { System.out.println("Maybe incorrect measurement!"); Stack<Parse> parents = new Stack<Parse>(); // get parent and update distance // if match return distance // if not match do it again } return parse.getSpan().compareTo(p.getSpan()); } }
public int compareTo(opennlp.tools.coref.mention.Parse p) { if (p == this) { return 0; } if (getSentenceNumber() < p.getSentenceNumber()) { return -1; } else if (getSentenceNumber() > p.getSentenceNumber()) { return 1; } else { if (parse.getSpan().getStart() == p.getSpan().getStart() && parse.getSpan().getEnd() == p.getSpan().getEnd()) { System.out.println("Maybe incorrect measurement!"); Stack<Parse> parents = new Stack<Parse>(); // get parent and update distance // if match return distance // if not match do it again } return parse.getSpan().compareTo(p.getSpan()); } }