public static class CleartkExtractor.Ngram extends Object implements CleartkExtractor.Context
CleartkExtractor.Context that aggregates the features of other contexts into a single "ngram" feature,
where the feature values are concatenated together in order to form a single value.| Constructor and Description |
|---|
CleartkExtractor.Ngram(CleartkExtractor.Context... contexts)
Constructs a
CleartkExtractor.Context which converts the features extracted by the argument contexts
into a single ngram feature where all feature values have been concatenated together. |
| Modifier and Type | Method and Description |
|---|---|
<SEARCH_T extends Annotation> |
extract(JCas jCas,
Annotation focusAnnotation,
CleartkExtractor.Bounds bounds,
Class<SEARCH_T> annotationClass,
FeatureExtractor1<SEARCH_T> extractor)
Extracts features in the given context.
|
String |
getName()
Gets the base feature name that will be used in
Features generated by this context. |
public CleartkExtractor.Ngram(CleartkExtractor.Context... contexts)
CleartkExtractor.Context which converts the features extracted by the argument contexts
into a single ngram feature where all feature values have been concatenated together. That
is, it takes everything provided by the contexts and makes a single feature value from it.
For example, the code "new Ngram(new Preceding(2), new Following(2)))" if run on token
annotations would return the feature "A_B_D_E" for the token "C" in the text "A B C D E".
That is, it creates a single ngram from the preceding context and following context. Please
see org.cleartk.ml.feature.extractor.CleartkExtractorTest.testNgram() to run this example.contexts - The contexts which should be combined into an ngram.public <SEARCH_T extends Annotation> List<Feature> extract(JCas jCas, Annotation focusAnnotation, CleartkExtractor.Bounds bounds, Class<SEARCH_T> annotationClass, FeatureExtractor1<SEARCH_T> extractor) throws CleartkExtractorException
CleartkExtractor.Contextextract in interface CleartkExtractor.ContextjCas - The JCas containing the focus annotation.focusAnnotation - The annotation whose context is to be searched.annotationClass - The type of annotation to be found in the context.extractor - The feature extractor that should be applied to each annotation found in the
context.CleartkExtractorExceptionpublic String getName()
CleartkExtractor.ContextFeatures generated by this context.
The actual feature names may include additional information (e.g. relative position), but
this base name should be used in all aggregating contexts like CleartkExtractor.Bag or CleartkExtractor.Ngram.getName in interface CleartkExtractor.ContextCopyright © 2014. All rights reserved.