/** * 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)); }
private boolean chainAnnotationExists(CAS aCas, String aType) { Type type = aCas.getTypeSystem().getType(aType); if (CasUtil.selectFS(aCas, type).size() == 0) { return false; } return true; } }
private boolean chainAnnotationExists(CAS aCas, String aType) { Type type = aCas.getTypeSystem().getType(aType); if (CasUtil.selectFS(aCas, type).size() == 0) { return false; } return true; } }
/** * Convenience method select all feature structure from the given type from an array. * * @param <T> * the JCas type. * @param array * a feature structure array. * @param type * the type. * @return A collection of the selected type. * @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a> */ public static <T extends TOP> Collection<T> select(final FSArray array, final Class<T> type) { return cast(CasUtil.selectFS(array, CasUtil.getType(array.getCAS(), type.getName()))); }
/** * Convenience method to iterator over all features structures of a given type. * * @param <T> * the iteration type. * @param jCas * the JCas containing the type system. * @param type * the type. * @return A collection of the selected type. * @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a> */ public static <T extends TOP> Collection<T> select(final JCas jCas, final Class<T> type) { return cast(CasUtil.selectFS(jCas.getCas(), getType(jCas, type))); }
selectFS(aCas, getType(aCas, layer.getName() + "Chain")));
List<FeatureStructure> chains = new ArrayList<>(selectFS(aCas, chainType)); List<AnnotationFS> links = new ArrayList<>(select(aCas, linkType));
/** * Find the chain head for the given link. * * @param aJCas the CAS. * @param aLink the link to search the chain for. * @return the chain. */ private FeatureStructure getChainForLink(JCas aJCas, AnnotationFS aLink) { Type chainType = getAnnotationType(aJCas.getCas()); for (FeatureStructure chainFs : selectFS(aJCas.getCas(), chainType)) { AnnotationFS linkFs = getFirstLink(chainFs); // Now we seek the link within the current chain while (linkFs != null) { if (BratAjaxCasUtil.isSame(linkFs, aLink)) { return chainFs; } linkFs = getNextLink(linkFs); } } // This should never happen unless the data in the CAS has been created erratically throw new IllegalArgumentException("Link not part of any chain"); }
/** * Find the chain head for the given link. * * @param aJCas the CAS. * @param aLink the link to search the chain for. * @return the chain. */ private FeatureStructure getChainForLink(JCas aJCas, AnnotationFS aLink) { Type chainType = CasUtil.getType(aJCas.getCas(), getChainTypeName()); for (FeatureStructure chainFs : selectFS(aJCas.getCas(), chainType)) { AnnotationFS linkFs = getFirstLink(chainFs); // Now we seek the link within the current chain while (linkFs != null) { if (WebAnnoCasUtil.isSame(linkFs, aLink)) { return chainFs; } linkFs = getNextLink(linkFs); } } // This should never happen unless the data in the CAS has been created wrongly throw new IllegalArgumentException("Link not part of any chain"); }
Renderer renderer = layerSupportRegistry.getLayerSupport(layer).getRenderer(layer); for (FeatureStructure fs : selectFS(jcas.getCas(), adapter.getAnnotationType(jcas.getCas()))) { Map<String, String> renderedFeatures = renderer.getFeatures(adapter, fs, features);
/** * Find the chain head for the given link. * * @param aJCas the CAS. * @param aLink the link to search the chain for. * @return the chain. */ private FeatureStructure getChainForLink(JCas aJCas, AnnotationFS aLink) { Type chainType = CasUtil.getType(aJCas.getCas(), getChainTypeName()); for (FeatureStructure chainFs : selectFS(aJCas.getCas(), chainType)) { AnnotationFS linkFs = getFirstLink(chainFs); // Now we seek the link within the current chain while (linkFs != null) { if (WebAnnoCasUtil.isSame(linkFs, aLink)) { return chainFs; } linkFs = getNextLink(linkFs); } } // This should never happen unless the data in the CAS has been created wrongly throw new IllegalArgumentException("Link not part of any chain"); }
Renderer renderer = layerSupportRegistry.getLayerSupport(layer).getRenderer(layer); for (FeatureStructure fs : selectFS(jcas.getCas(), adapter.getAnnotationType(jcas.getCas()))) { Map<String, String> renderedFeatures = renderer.getFeatures(adapter, fs, features);
Feature chainFirst = type.getFeatureByBaseName(FIRST); int chainNo = 1; for (FeatureStructure chainFs : selectFS(aJCas.getCas(), type)) { AnnotationFS linkFs = (AnnotationFS) chainFs.getFeatureValue(chainFirst); AnnotationUnit unit = getUnit(linkFs.getBegin(), linkFs.getEnd(), linkFs.getCoveredText());
Feature chainFirst = type.getFeatureByBaseName(FIRST); int chainNo = 1; for (FeatureStructure chainFs : selectFS(aJCas.getCas(), type)) { AnnotationFS linkFs = (AnnotationFS) chainFs.getFeatureValue(chainFirst); AnnotationUnit unit = getUnit(linkFs.getBegin(), linkFs.getEnd(),
Feature chainFirst = type.getFeatureByBaseName(FIRST); int chainNo = 1; for (FeatureStructure chainFs : selectFS(aJCas.getCas(), type)) { AnnotationFS linkFs = (AnnotationFS) chainFs.getFeatureValue(chainFirst); AnnotationUnit unit = getUnit(linkFs.getBegin(), linkFs.getEnd(),
chainLoop: for (FeatureStructure chainFs : selectFS(aJCas.getCas(), chainType)) { AnnotationFS linkFs = getFirstLink(chainFs);
protected void afterProcess(JCas aInput, JCas aOutput) { // Copy the annotation types mentioned in PARAM_TYPES_TO_COPY // We have do do this in the afterProcess() phase, because otherwise the SofA in the // target CAS does not exist yet. CAS inputCas = aInput.getCas(); CasCopier copier = new CasCopier(inputCas, aOutput.getCas()); Feature mDestSofaFeature = aOutput.getTypeSystem() .getFeatureByFullName(CAS.FEATURE_FULL_NAME_SOFA); for (String typeName : typesToCopy) { for (FeatureStructure fs : selectFS(inputCas, getType(inputCas, typeName))) { if (!copier.alreadyCopied(fs)) { FeatureStructure fsCopy = copier.copyFs(fs); // Make sure that the sofa annotation in the copy is set if (fs instanceof AnnotationBaseFS) { FeatureStructure sofa = fsCopy.getFeatureValue(mDestSofaFeature); if (sofa == null) { fsCopy.setFeatureValue(mDestSofaFeature, aOutput.getSofa()); } } aOutput.addFsToIndexes(fsCopy); } } } }
chainLoop: for (FeatureStructure chainFs : selectFS(aJCas.getCas(), chainType)) { AnnotationFS linkFs = getFirstLink(chainFs);
chainLoop: for (FeatureStructure chainFs : selectFS(aJCas.getCas(), chainType)) { AnnotationFS linkFs = getFirstLink(chainFs);
Feature endFeature = annotationType.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_END); for (FeatureStructure fs : selectFS(inputCas, getType(inputCas, typeName))) { if (!copier.alreadyCopied(fs)) { FeatureStructure fsCopy = copier.copyFs(fs);