本文整理了Java中opennlp.tools.util.Span.compareTo()
方法的一些代码示例,展示了Span.compareTo()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Span.compareTo()
方法的具体详情如下:
包路径:opennlp.tools.util.Span
类名称:Span
方法名:compareTo
[英]Compares the specified span to the current span.
[中]将指定范围与当前范围进行比较。
代码示例来源:origin: apache/opennlp
/**
* 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);
}
代码示例来源:origin: apache/opennlp
/**
* 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);
}
代码示例来源:origin: apache/opennlp
/**
* 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);
}
代码示例来源:origin: apache/opennlp
/**
* 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);
}
代码示例来源:origin: apache/opennlp
/**
* 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);
}
代码示例来源:origin: apache/opennlp
/**
* 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);
}
代码示例来源:origin: apache/opennlp
/**
* 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);
}
代码示例来源:origin: apache/opennlp
/**
* 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);
}
代码示例来源:origin: apache/opennlp-sandbox
public int compareTo(Mention e) {
return span.compareTo(e.span);
}
代码示例来源:origin: Ailab403/ailab-mltk4j
public int compareTo(Mention e) {
return span.compareTo(e.span);
}
代码示例来源:origin: spinscale/elasticsearch-opennlp-plugin
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;
}
代码示例来源:origin: org.cogroo.lang.pt_br/cogroo-addon-pt_br
public int compareTo(Omission o) {
return span.compareTo(o.getSpan());
}
代码示例来源:origin: cogroo/cogroo4
public int compareTo(Omission o) {
return span.compareTo(o.getSpan());
}
代码示例来源:origin: org.cogroo/cogroo-gc
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());
}
}
代码示例来源:origin: cogroo/cogroo4
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());
}
}
代码示例来源:origin: Ailab403/ailab-mltk4j
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());
}
}
代码示例来源:origin: apache/opennlp-sandbox
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());
}
}
内容来源于网络,如有侵权,请联系作者删除!