Class TokenBuilder<TOKEN_TYPE extends Annotation,SENTENCE_TYPE extends Annotation>
java.lang.Object
org.apache.uima.fit.testing.factory.TokenBuilder<TOKEN_TYPE,SENTENCE_TYPE>
- Type Parameters:
TOKEN_TYPE
- the type system token type (e.g.org.apache.uima.fit.examples.type.Token
)SENTENCE_TYPE
- the type system sentence type (e.g.org.apache.uima.fit.examples.type.Sentence
)
public class TokenBuilder<TOKEN_TYPE extends Annotation,SENTENCE_TYPE extends Annotation>
extends Object
This class provides convenience methods for creating tokens and sentences and add them to a
JCas
.-
Constructor Summary
ConstructorDescriptionTokenBuilder
(Class<TOKEN_TYPE> aTokenClass, Class<SENTENCE_TYPE> aSentenceClass) CallsTokenBuilder(Class, Class, String, String)
with the last two arguments as null.TokenBuilder
(Class<TOKEN_TYPE> aTokenClass, Class<SENTENCE_TYPE> aSentenceClass, String aPosFeatureName, String aStemFeatureName) Instantiates a TokenBuilder with the type system information that the builder needs to build tokens. -
Method Summary
Modifier and TypeMethodDescriptionvoid
buildTokens
(JCas aJCas, String aText) Builds white-space delimited tokens from the input text.void
buildTokens
(JCas aJCas, String aText, String aTokensString) void
buildTokens
(JCas aJCas, String aText, String aTokensString, String aPosTagsString) void
buildTokens
(JCas aJCas, String aText, String aTokensString, String aPosTagsString, String aStemsString) Build tokens for the given text, tokens, part-of-speech tags, and word stems.static <T extends Annotation,
S extends Annotation>
TokenBuilder<T, S> Instantiates a TokenBuilder with the type system information that the builder needs to build tokens.void
setPosFeatureName
(String aPosFeatureName) Set the feature name for the part-of-speech tag for your token type.void
setStemFeatureName
(String aStemFeatureName) Set the feature name for the stem for your token type.
-
Constructor Details
-
TokenBuilder
CallsTokenBuilder(Class, Class, String, String)
with the last two arguments as null.- Parameters:
aTokenClass
- the class of your token type from your type system (e.g. org.apache.uima.fit.type.Token.class)aSentenceClass
- the class of your sentence type from your type system (e.g. org.apache.uima.fit.type.Sentence.class)
-
TokenBuilder
public TokenBuilder(Class<TOKEN_TYPE> aTokenClass, Class<SENTENCE_TYPE> aSentenceClass, String aPosFeatureName, String aStemFeatureName) Instantiates a TokenBuilder with the type system information that the builder needs to build tokens.- Parameters:
aTokenClass
- the class of your token type from your type system (e.g. org.apache.uima.fit.type.Token.class)aSentenceClass
- the class of your sentence type from your type system (e.g. org.apache.uima.fit.type.Sentence.class)aPosFeatureName
- the feature name for the part-of-speech tag for your token type. This assumes that there is a single string feature for which to put your pos tag. null is an ok value.aStemFeatureName
- the feature name for the stem for your token type. This assumes that there is a single string feature for which to put your stem. null is an ok value.
-
-
Method Details
-
create
public static <T extends Annotation,S extends Annotation> TokenBuilder<T,S> create(Class<T> aTokenClass, Class<S> aSentenceClass) Instantiates a TokenBuilder with the type system information that the builder needs to build tokens.- Type Parameters:
T
- the type system token type (e.g. org.apache.uima.fit.examples.type.Token)S
- the type system sentence type (e.g.org.apache.uima.fit.examples.type.Sentence
)- Parameters:
aTokenClass
- the class of your token type from your type system (e.g.org.apache.uima.fit.type.Token
)aSentenceClass
- the class of your sentence type from your type system (e.g.org.apache.uima.fit.type.Sentence
)- Returns:
- the builder.
-
setPosFeatureName
Set the feature name for the part-of-speech tag for your token type. This assumes that there is a single string feature for which to put your pos tag. null is an ok value.- Parameters:
aPosFeatureName
- the part-of-speech feature name.
-
setStemFeatureName
Set the feature name for the stem for your token type. This assumes that there is a single string feature for which to put your stem. null is an ok value.- Parameters:
aStemFeatureName
- the stem feature name.
-
buildTokens
Builds white-space delimited tokens from the input text.- Parameters:
aJCas
- the JCas to add the Token annotations toaText
- the text to initialize theJCas
with
-
buildTokens
- Parameters:
aJCas
- the JCas to add the Token annotations toaText
- the text to initialize theJCas
withaTokensString
- the tokensString must have the same non-white space characters as the text. The tokensString is used to identify token boundaries using white space - i.e. the only difference between the 'text' parameter and the 'tokensString' parameter is that the latter may have more whitespace characters. For example, if the text is "She ran." then the tokensString might be "She ran ."- See Also:
-
buildTokens
- Parameters:
aJCas
- the JCas to add the Token annotations toaText
- the text to initialize theJCas
withaTokensString
- the tokensString must have the same non-white space characters as the text. The tokensString is used to identify token boundaries using white space - i.e. the only difference between the 'text' parameter and the 'tokensString' parameter is that the latter may have more whitespace characters. For example, if the text is "She ran." then the tokensString might be "She ran ."aPosTagsString
- the posTagsString should be a space delimited string of part-of-speech tags - one for each token- See Also:
-
buildTokens
public void buildTokens(JCas aJCas, String aText, String aTokensString, String aPosTagsString, String aStemsString) Build tokens for the given text, tokens, part-of-speech tags, and word stems.- Parameters:
aJCas
- the JCas to add the Token annotations toaText
- the text to initialize theJCas
withaTokensString
- the tokensString must have the same non-white space characters as the text. The tokensString is used to identify token boundaries using white space - i.e. the only difference between the 'text' parameter and the 'tokensString' parameter is that the latter may have more whitespace characters. For example, if the text is "She ran." then the tokensString might be "She ran ."aPosTagsString
- the posTagsString should be a space delimited string of part-of-speech tags - one for each tokenaStemsString
- the stemsString should be a space delimited string of stems - one for each token
-