public interface Chunk extends Scored
Chunk interface specifies a slice of a character
sequence, a chunk type and a chunk score. It is important to keep
in mind that a chunk only stores character offsets into a character
sequence, not the character sequence itself. A chunk is almost
always associated with a Chunking consisting of a character
sequence and set of chunks over that sequence.
Equality for chunks is defined by the equality of the chunk's
components (see the method documentation of equals(Object)
for details). Hash codes are defined to be consistent with
equality (see the method documentation of hashCode() for
details).
Chunks may be constructed using static methods in the ChunkFactory class or they may be implemented directly.
The chunk interface extends the Scored interface, so
chunks may be ordered by the ScoredObject.comparator() and ScoredObject.reverseComparator() comparators.
Note that these comparators are not consistent with equality, but
may be used for sorting chunks in score order in arrays.
Chunks may be ordered by their offsets using TEXT_ORDER_COMPARATOR. Ordering the chunks of a given chunking
using this comparator produces an ordering based on first
appearance (and length in the case of ties). An alternative
ordering is LONGEST_MATCH_ORDER_COMPARATOR.
| Modifier and Type | Field and Description |
|---|---|
static Comparator<Chunk> |
LONGEST_MATCH_ORDER_COMPARATOR
Compares two chunks based on their text position.
|
static Comparator<Chunk> |
TEXT_ORDER_COMPARATOR
Compares two chunks based on their text position.
|
| Modifier and Type | Method and Description |
|---|---|
int |
end()
Returns the index of one past the last character in this chunk.
|
boolean |
equals(Object that)
Returns
true if the specified object is a chunk
that is equal to this chunk. |
int |
hashCode()
Returns this chunk's hash code.
|
double |
score()
Returns the score of this chunk.
|
int |
start()
Returns the index of the first character in this chunk.
|
String |
type()
Returns the type of this chunk.
|
static final Comparator<Chunk> TEXT_ORDER_COMPARATOR
equals(Object), but may be used for
sorting using Arrays.sort(Object[],Comparator).static final Comparator<Chunk> LONGEST_MATCH_ORDER_COMPARATOR
This comparator is not compatible with equals(Object), but may be used for sorting using Arrays.sort(Object[],Comparator).
int start()
int end()
String type()
double score()
boolean equals(Object that)
true if the specified object is a chunk
that is equal to this chunk. Another chunk is equal to this
one if they have the same start, end, type and score.Copyright © 2019 Alias-i, Inc.. All rights reserved.