Package opennlp.tools.util
Klasse Span
java.lang.Object
opennlp.tools.util.Span
- Alle implementierten Schnittstellen:
Serializable
,Comparable<Span>
- Bekannte direkte Unterklassen:
LinkedSpan
,MascSentence
,MascToken
,MascWord
Class for storing start and end integer offsets.
- Siehe auch:
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungint
Compares the specifiedSpan
to the current span.boolean
contains
(int index) An index with the value of end is considered outside theSpan
.boolean
Identicalspans
are considered to contain each other.boolean
Checks if the specifiedSpan
crosses this span.boolean
getCoveredText
(CharSequence text) int
getEnd()
Note: that the returned index is one past the actual end of the span in the text, or the first element past the end of the span.double
getProb()
int
getStart()
getType()
int
hashCode()
boolean
intersects
(Span s) Checks if the specifiedSpan
intersects with this span.int
length()
static String[]
spansToStrings
(Span[] spans, CharSequence s) static String[]
spansToStrings
(Span[] spans, String[] tokens) boolean
startsWith
(Span s) toString()
trim
(CharSequence text)
-
Konstruktordetails
-
Span
Initializes a newSpan
. Sets the prob to0
as default.- Parameter:
s
- The start position of aSpan
. Must be equal to or greater than0
. Must not be greater thane
.e
- The end position of aSpan
, which is+1
more than the last element in the span. Must be equal to or greater than0
.type
- the type of the span- Löst aus:
IllegalArgumentException
- Thrown if given parameters are invalid.
-
Span
Initializes a newSpan
.- Parameter:
s
- The start position of aSpan
. Must be equal to or greater than0
. Must not be greater thane
.e
- The end position of aSpan
, which is+1
more than the last element in the span. Must be equal to or greater than0
.type
- The type of theSpan
prob
- The probability of theSpan
.- Löst aus:
IllegalArgumentException
- Thrown if given parameters are invalid.
-
Span
public Span(int s, int e) Initializes a newSpan
. Sets the prob to0
as default.- Parameter:
s
- The start position of aSpan
. Must be equal to or greater than0
. Must not be greater thane
.e
- The end position of aSpan
, which is+1
more than the last element in the span. Must be equal to or greater than0
.- Löst aus:
IllegalArgumentException
- Thrown if given parameters are invalid.
-
Span
public Span(int s, int e, double prob) Initializes a newSpan
. Sets the prob to0
as default.- Parameter:
s
- The start position of aSpan
. Must be equal to or greater than0
. Must not be greater thane
.e
- The end position of aSpan
, which is+1
more than the last element in the span. Must be equal to or greater than0
.prob
- The probability of theSpan
- Löst aus:
IllegalArgumentException
- Thrown if given parameters are invalid.
-
Span
- Parameter:
span
- The existingSpan
.offset
- The positive or negative shift offset.- Löst aus:
IllegalArgumentException
- Thrown if given parameters are invalid.
-
Span
Creates a new immutableSpan
based on an existingSpan
, where the existingSpan
did not include the probability.- Parameter:
span
- TheSpan
that has no prob or the prob is incorrect and a newSpan
must be generated.prob
- The probability of theSpan
.- Löst aus:
IllegalArgumentException
- Thrown if given parameters are invalid.
-
-
Methodendetails
-
getStart
public int getStart()- Gibt zurück:
- Retrieves the start of a
Span
. Guaranteed to be greater than0
.
-
getEnd
public int getEnd()Note: that the returned index is one past the actual end of the span in the text, or the first element past the end of the span.- Gibt zurück:
- Retrieves the end of a
Span
. Guaranteed to be greater than0
.
-
getType
- Gibt zurück:
- Retrieves the type of a
Span
ornull
if not set.
-
length
public int length()- Gibt zurück:
- Returns the length of a
Span
. Guaranteed to be greater than0
.
-
contains
Identicalspans
are considered to contain each other. -
contains
public boolean contains(int index) An index with the value of end is considered outside theSpan
.- Parameter:
index
- the index to test with thisSpan
.- Gibt zurück:
true
if the span contains this specified index,false
otherwise.
-
startsWith
- Parameter:
s
- TheSpan
to compare with this span.- Gibt zurück:
true
if the specified span starts with this span and is contained in this span,false
otherwise
-
intersects
Checks if the specifiedSpan
intersects with this span.- Parameter:
s
- TheSpan
to compare with this span.- Gibt zurück:
true
is the spans overlap,false
otherwise.
-
crosses
Checks if the specifiedSpan
crosses this span. -
getCoveredText
- Parameter:
text
- Thetext
to analyze.- Gibt zurück:
- Retrieves the (sub)string covered by the current
Span
of the specified text. - Löst aus:
IllegalArgumentException
- Thrown if parameters violated a constraint.
-
trim
-
compareTo
Compares the specifiedSpan
to the current span.- Angegeben von:
compareTo
in SchnittstelleComparable<Span>
- Parameter:
s
- TheSpan
instance to compare against.- Siehe auch:
-
hashCode
public int hashCode() -
equals
-
toString
-
spansToStrings
- Parameter:
spans
- The array used as input.s
- TheCharSequence
used to compute covered text.- Gibt zurück:
- The converted array of strings.
-
spansToStrings
-
getProb
public double getProb()- Gibt zurück:
- Retrieves the probability represented by a
Span
.
-