public class ChunkAndCharSeq extends Object implements Scored
ChunkAndCharSeq is an immutable composite of a
chunk and a character sequence. This class also implements the
Scored interface based on chunk score (see score()), so that elements may be sorted by score.
Equality for the composite is based on object equality. This means that two chunk and character sequences may have the same span over the same character sequence with the same type and same score and still be different.
Instances of this class are returned in the sets produced by a
ChunkingEvaluation and in a SentenceEvaluation.
| Constructor and Description |
|---|
ChunkAndCharSeq(Chunk chunk,
CharSequence cSeq)
Construct a composite of the specified chunk and sequence.
|
| Modifier and Type | Method and Description |
|---|---|
String |
charSequence()
Return the underlying character sequence for this chunk.
|
Chunk |
chunk()
Return the chunk underlying this compositie chunk and character
sequence.
|
boolean |
equals(Object that)
Returns
true if the specified object is a chunk
and character sequence structurally equivalent to this one. |
int |
hashCode()
Returns the cached hash code for this chunk and character
sequence.
|
double |
score()
Return the underlying chunk's score.
|
String |
span()
Return the characters spanned by this chunk.
|
CharSequence |
spanEndContext(int contextLength)
Return a span of characters centered around the end of this
chunk plus or minus the context length.
|
CharSequence |
spanStartContext(int contextLength)
Return a span of characters centered around the start of this
chunk plus or minus the context length.
|
String |
toString()
Returns a string-based representation of this chunk and
character sequence.
|
public ChunkAndCharSeq(Chunk chunk, CharSequence cSeq)
chunk - The underlying chunk.cSeq - The character sequence for the chunk.IllegalArgumentException - If the chunk bounds exceed the
sequence length.public int hashCode()
public boolean equals(Object that)
true if the specified object is a chunk
and character sequence structurally equivalent to this one.
For equality, the character sequences must be equivalent and
the chunks must be equivalent.public String span()
sequence(), running from this chunk's start index,
chunk().start(), up to but not including the chunk's
end index, chunk().end().public CharSequence spanStartContext(int contextLength)
sequence(),
running from this chunk's start index - contextLen,
chunk().start(), up to not including start index +
contextLen.contextLength - The number of characters before and after the
chunk start to retrieve.IllegalArgumentException - If the contextLength < 1.public CharSequence spanEndContext(int contextLength)
sequence(),
running from this chunk's end index - contextLength,
chunk().end(), up to not including end index +
contextLength.contextLength - The number of characters before and after the
chunk end to retrieve.IllegalArgumentException - If the contextLength < 1.public String charSequence()
public Chunk chunk()
public double score()
Copyright © 2016 Alias-i, Inc.. All rights reserved.