String sofaName = annotationDescription.getSofa();
sofaName = sofaName == null ? CAS.NAME_DEFAULT_SOFA : sofaName;
// create tokenstream from annotations
AnnotationTokenStream annotationTokenStream = null;
String typeName = annotationDescription.getType();
if (annotationDescription.getFeatureDescriptions().size() == 0)
try {
annotationTokenStream = new AnnotationTokenStream(jCas, sofaName, typeName);
} catch (InvalidTokenSourceException e) {
throw createException(annotationDescription, e);
}
else {
String featurePath = annotationDescription.getFeaturePath();
String delimiter = annotationDescription.getFeatureValueDelimiterString();
Collection<FeatureDescription> featureDescriptions = annotationDescription.getFeatureDescriptions();
List<String> featureNames = extractFeatureNames(featureDescriptions);
Map<String, Format> featureFormats = extractFeatureFormats(featureDescriptions);
if (featurePath != null)
try {
annotationTokenStream = new AnnotationTokenStream(jCas, sofaName, typeName, featurePath,
featureNames, delimiter, featureFormats);
} catch (InvalidTokenSourceException e) {
throw createException(annotationDescription, e);
}
else
try {
annotationTokenStream = new AnnotationTokenStream(jCas, sofaName, typeName, featureNames,
delimiter, featureFormats);
} catch (InvalidTokenSourceException e) {
throw createException(annotationDescription, e);
}