@Test public void testBuildFeatureAnnotationTokenStream() throws Exception{ annotation1.setFeatureString("token1Feature1"); annotationDescription.getFeatureDescriptions().add(new FeatureDescription("featureString")); AnnotationTokenStream annotationTokenStream = annotationTokenStreamBuilder.createAnnotationTokenStream(cas, annotationDescription); assertEquals(annotation1Type, annotationTokenStream.getAnnotationType()); assertEquals(1, annotationTokenStream.getFeatureNames().size()); assertEquals(0, annotationTokenStream.getFeatureFormats().size()); assertEquals("token1Feature1", annotationTokenStream.next(new Token()).term()); }
public AnnotationTokenStream createAnnotationTokenStream(JCas jCas, AnnotationDescription annotationDescription) throws AnnotationTokenStreamBuildingException { String sofaName = annotationDescription.getSofa(); sofaName = sofaName == null ? CAS.NAME_DEFAULT_SOFA : sofaName; 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); } } return annotationTokenStream; }
AnnotationTokenStreamBuilder { public AnnotationTokenStream createAnnotationTokenStream(JCas jCas, AnnotationDescription annotationDescription) throws AnnotationTokenStreamBuildingException { String sofaName = annotationDescription.getSofa(); sofaName = sofaName == null ? CAS.NAME_DEFAULT_SOFA : sofaName; 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); } } return annotationTokenStream; } }
AnnotationTokenStreamBuilder { public AnnotationTokenStream createAnnotationTokenStream(JCas jCas, AnnotationDescription annotationDescription) throws AnnotationTokenStreamBuildingException { String sofaName = annotationDescription.getSofa(); sofaName = sofaName == null ? CAS.NAME_DEFAULT_SOFA : sofaName; 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); } } return annotationTokenStream; }  }
AnnotationTokenStreamBuilder { public AnnotationTokenStream createAnnotationTokenStream(JCas jCas, AnnotationDescription annotationDescription) throws AnnotationTokenStreamBuildingException { String sofaName = annotationDescription.getSofa(); sofaName = sofaName == null ? CAS.NAME_DEFAULT_SOFA : sofaName; 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); } } return annotationTokenStream; }  AnnotationTokenStream createAnnotationTokenStream(JCas jCas,
          AnnotationDescription annotationDescription); }
AnnotationTokenStreamBuilder { public AnnotationTokenStream createAnnotationTokenStream(JCas jCas, AnnotationDescription annotationDescription) throws AnnotationTokenStreamBuildingException { String sofaName = annotationDescription.getSofa(); sofaName = sofaName == null ? CAS.NAME_DEFAULT_SOFA : sofaName; 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); } } return annotationTokenStream; }  AnnotationTokenStream createAnnotationTokenStream(JCas jCas,
          AnnotationDescription annotationDescription);  }