List of usage examples for opennlp.tools.util Span contains
public boolean contains(int index)
From source file:opennlp.tools.util.Span.java
/** * Test for {@link Span#contains(int)}. *///from w w w . j a v a2 s .c o m public void testContainsInt() { Span a = new Span(10, 300); Assert.assertFalse(a.contains(9)); Assert.assertTrue(a.contains(10)); Assert.assertTrue(a.contains(200)); Assert.assertTrue(a.contains(300)); Assert.assertFalse(a.contains(301)); }
From source file:opennlp.tools.util.Span.java
/** * Test for {@link Span#contains(Span)}. *//* w ww .j a v a2 s.c o m*/ public void testContainsWithEqual() { Span a = new Span(500, 900); Assert.assertEquals(true, a.contains(a)); }
From source file:opennlp.tools.util.Span.java
/** * Test for {@link Span#contains(Span)}. *///from ww w .java 2s .c o m public void testContains() { Span a = new Span(500, 900); Span b = new Span(520, 600); Assert.assertEquals(true, a.contains(b)); }
From source file:opennlp.tools.util.Span.java
/** * Test for {@link Span#contains(Span)}. *//*from w w w.j av a 2s. c om*/ public void testContainsWithLowerIntersect() { Span a = new Span(500, 900); Span b = new Span(450, 1000); Assert.assertEquals(false, a.contains(b)); }
From source file:opennlp.tools.util.Span.java
/** * Test for {@link Span#contains(Span)}. *///from w w w . j ava 2 s. com public void testContainsWithHigherIntersect() { Span a = new Span(500, 900); Span b = new Span(500, 1000); Assert.assertEquals(false, a.contains(b)); }
From source file:opennlp.tools.util.Span.java
/** * Returns true if the specified span intersects with this span. * /*from ww w. ja v a2s. c o m*/ * @param s The span to compare with this span. * * @return true is the spans overlap; false otherwise. */ public boolean intersects(Span s) { int sstart = s.getStart(); //either s's start is in this or this' start is in s return this.contains(s) || s.contains(this) || getStart() <= sstart && sstart < getEnd() || sstart <= getStart() && getStart() < s.getEnd(); }
From source file:opennlp.tools.util.Span.java
/** * Returns true is the specified span crosses this span. * //from w w w . jav a 2s.c o m * @param s The span to compare with this span. * * @return true is the specified span overlaps this span and contains a * non-overlapping section; false otherwise. */ public boolean crosses(Span s) { int sstart = s.getStart(); //either s's start is in this or this' start is in s return !this.contains(s) && !s.contains(this) && (getStart() <= sstart && sstart < getEnd() || sstart <= getStart() && getStart() < s.getEnd()); }