@Override public Type getAnnotationType(CAS cas) { return CasUtil.getType(cas, annotationTypeName); }
@Override public Type getAnnotationType(CAS cas) { return CasUtil.getType(cas, annotationTypeName); }
/** * Get the CAS type for the given JCas wrapper class. * * @param cas * the CAS hosting the type system. * @param type * the JCas wrapper class. * @return the CAS type. */ public static Type getType(CAS cas, Class<?> type) { return getType(cas, type.getName()); }
/** * Convenience method to iterator over all annotations. * * @param aCas * the CAS hosting the type system. * @return A collection of the selected type. * @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a> */ public static Collection<AnnotationFS> selectAll(final CAS aCas) { return select(aCas, getType(aCas, CAS.TYPE_NAME_ANNOTATION)); }
/** * Convenience method to iterator over all features structures. * * @param aCas * the CAS hosting the type system. * @return A collection of the selected type. * @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a> */ public static Collection<FeatureStructure> selectAllFS(final CAS aCas) { return selectFS(aCas, getType(aCas, CAS.TYPE_NAME_TOP)); }
/** * Get the CAS type for the given JCas wrapper class type. * * @param jCas * the JCas containing the type system. * @param type * the JCas wrapper class type. * @return the CAS type. */ public static Type getType(JCas jCas, Class<?> type) { return CasUtil.getType(jCas.getCas(), type); }
@Override public Type getAnnotationType(CAS aCas) { return CasUtil.getType(aCas, getAnnotationTypeName()); }
/** * Get the CAS type of the this {@link TypeAdapter} * * @param cas * the CAS. * @return the type. */ default Type getAnnotationType(CAS cas) { return CasUtil.getType(cas, getAnnotationTypeName()); }
@Override public Type getAnnotationType(CAS aCas) { return CasUtil.getType(aCas, getAnnotationTypeName()); }
/** * Get the CAS type of the this {@link TypeAdapter} * * @param cas * the CAS. * @return the type. */ default Type getAnnotationType(CAS cas) { return CasUtil.getType(cas, getAnnotationTypeName()); }
@Override public Type getAnnotationType(CAS cas) { return CasUtil.getType(cas, getAnnotationTypeName()); }
@Override public void init(JCas aJCas) { sentences = select(aJCas, Sentence.class).iterator(); CAS cas = aJCas.getCas(); Type chunkType = CasUtil.getType(cas, Chunk.class); Feature chunkTagFeature = chunkType.getFeatureByBaseName("chunkValue"); chunkEncoder = new IobEncoder(cas, chunkType, chunkTagFeature); }
private boolean containsTargetAnnotation(Recommender aRecommender, CAS aCas) { Type type = CasUtil.getType(aCas, aRecommender.getLayer().getName()); return CasUtil.iterator(aCas, type).hasNext(); }
private void removePredictedAnnotations(CAS aCas) { Type type = CasUtil.getType(aCas, getPredictedType()); for (AnnotationFS annotationFS : CasUtil.select(aCas, type)) { aCas.removeFsFromIndexes(annotationFS); } }
private Optional<AnnotationFS> getMatchingAnnotation(CAS aCas, LearningRecord aRecord) { Type type = CasUtil.getType(aCas, alStateModel.getObject().getLayer().getName()); Feature feature = type.getFeatureByBaseName(aRecord.getAnnotationFeature().getName()); return selectAt(aCas, type, aRecord.getOffsetCharacterBegin(), aRecord.getOffsetCharacterEnd()).stream() .filter(fs -> aRecord.getAnnotation().equals(fs.getFeatureValueAsString(feature))) .findFirst(); }
@Override public List<String> getAnnotation(JCas aJcas, AnnotationFeature aFeature, int begin, int end) { Type type = getType(aJcas.getCas(), getAnnotationTypeName()); List<String> annotations = new ArrayList<String>(); for (AnnotationFS fs : selectCovered(aJcas.getCas(), type, begin, end)) { Feature labelFeature = fs.getType().getFeatureByBaseName(aFeature.getName()); annotations.add(fs.getFeatureValueAsString(labelFeature)); } return annotations; }
/** * Create a new link annotation. Already adds the chain to the CAS. */ private AnnotationFS newLink(JCas aJCas, int aBegin, int aEnd) { Type linkType = CasUtil.getType(aJCas.getCas(), getAnnotationTypeName()); AnnotationFS newLink = aJCas.getCas().createAnnotation(linkType, aBegin, aEnd); aJCas.getCas().addFsToIndexes(newLink); return newLink; }
/** * Create a new link annotation. Already adds the chain to the CAS. */ private AnnotationFS newLink(JCas aJCas, int aBegin, int aEnd) { Type linkType = CasUtil.getType(aJCas.getCas(), getAnnotationTypeName()); AnnotationFS newLink = aJCas.getCas().createAnnotation(linkType, aBegin, aEnd); aJCas.getCas().addFsToIndexes(newLink); return newLink; }
@Override public void updateFeature(JCas aJcas, AnnotationFeature aFeature,int aAddress, String aValue) { Type type = CasUtil.getType(aJcas.getCas(), aFeature.getLayer().getName()+LINK); Feature feature = type.getFeatureByBaseName(aFeature.getName()); FeatureStructure fs = BratAjaxCasUtil.selectByAddr(aJcas, FeatureStructure.class, aAddress); fs.setFeatureValueFromString(feature, aValue); }
/** * Create a new chain head feature structure. Already adds the chain to the CAS. */ private FeatureStructure newChain(JCas aJCas, AnnotationFS aFirstLink) { Type chainType = CasUtil.getType(aJCas.getCas(), getChainTypeName()); FeatureStructure newChain = aJCas.getCas().createFS(chainType); newChain.setFeatureValue(chainType.getFeatureByBaseName(getChainFirstFeatureName()), aFirstLink); aJCas.addFsToIndexes(newChain); return newChain; }