|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.aliasi.sentences.AbstractSentenceModel
public abstract class AbstractSentenceModel
An AbstractSentenceModel implements a sentence model
in terms of the method that adds indices to the collection.
Subclasses must only implement the method boundaryIndices(String[],String[],int,int,Collection), which adds
an Integer to the collection for each token index
which is sentence final.
The abstract model also adds
the method boundaryIndices(String[],String[],int,int) for
operating over slices of parallel arrays of tokens and whitespaces.
The static utility methods verifyBounds(String[],String[],int,int)
and verifyTokensWhitespaces(String[],String[]) may be used
by subclasses to verify that the inputs to the sentence detection
methods are legal.
| Constructor Summary | |
|---|---|
protected |
AbstractSentenceModel()
Construct an abstract sentence model. |
| Method Summary | |
|---|---|
int[] |
boundaryIndices(String[] tokens,
String[] whitespaces)
Returns an array of indices of sentence-final tokens. |
int[] |
boundaryIndices(String[] tokens,
String[] whitespaces,
int start,
int length)
Returns an array of indices of sentence-final tokens for the slice of the token and whitespace arrays specified. |
abstract void |
boundaryIndices(String[] tokens,
String[] whitespaces,
int start,
int length,
Collection<Integer> indices)
Adds the sentence final token indices as Integer
instances to the specified collection, only considering tokens
between index start and end-1
inclusive. |
protected static void |
verifyBounds(String[] tokens,
String[] whitespaces,
int start,
int length)
Throws an illegal argument exception if the arrays of tokens is not as long as the start plus length, or if the array of whitespaces is not at least one element longer than the start plus length. |
protected static void |
verifyTokensWhitespaces(String[] tokens,
String[] whitespaces)
Throws an illegal argument exception if the array of whitespaces is not one longer than the array of tokens. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected AbstractSentenceModel()
| Method Detail |
|---|
public int[] boundaryIndices(String[] tokens,
String[] whitespaces)
If this method is overridden in a subclass, the static
method verifyTokensWhitespaces(String[],String[]) should
be called to verify that the arguments are valid.
boundaryIndices in interface SentenceModeltokens - Array of tokens to annotate.whitespaces - Array of whitespaces to annotate.
IllegalArgumentException - If the array of whitespaces is
not one element longer than the array of tokens.
public int[] boundaryIndices(String[] tokens,
String[] whitespaces,
int start,
int length)
If this method is overridden in a subclass, the static
method verifyBounds(String[],String[],int,int) should
be called by implementations to verify that the arguments are
valid.
tokens - Array of tokens to annotate.whitespaces - Array of whitespaces to annotate.start - Index of first token to annotate.length - Number of tokens to annotate.
IllegalArgumentException - If the array of whitespaces is
not one element longer than the array of tokens.
public abstract void boundaryIndices(String[] tokens,
String[] whitespaces,
int start,
int length,
Collection<Integer> indices)
Integer
instances to the specified collection, only considering tokens
between index start and end-1
inclusive.
The abstract implementations provide an array list for the collection of indices, and results will be returned in the order they are added to the collection.
The static method verifyBounds(String[],String[],int,int) should be called by
implementations to verify that the arguments are valid.
boundaryIndices in interface SentenceModeltokens - Array of tokens to annotate.whitespaces - Array of whitespaces to annotate.start - Index of first token to annotate.length - Number of tokens to annotate.indices - Collection into which to write the boundary
indices.
IllegalArgumentException - If the array of whitespaces
and tokens is not long enough for the start and length parameters.
protected static void verifyBounds(String[] tokens,
String[] whitespaces,
int start,
int length)
tokens - Array of tokens to annotate.whitespaces - Array of whitespaces to annotate.start - Index of first token to annotate.length - Number of tokens to annotate.
IllegalArgumentException - If the array of whitespaces
and tokens is not long enough for the start and length parameters.
protected static void verifyTokensWhitespaces(String[] tokens,
String[] whitespaces)
tokens - Array of tokens to annotate.whitespaces - Array of whitespaces to annotate.
IllegalArgumentException - If the array of whitespaces
is not one longer than the array of tokens.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||