protected AnnotationFS createAnnotation(CAS cas, int offset, Parse parse) { Parse[] parseChildren = parse.getChildren(); AnnotationFS[] parseChildAnnotations = new AnnotationFS[parseChildren.length]; // do this for all children for (int i = 0; i < parseChildren.length; i++) { parseChildAnnotations[i] = createAnnotation(cas, offset, parseChildren[i]); } AnnotationFS parseAnnotation = cas.createAnnotation(mParseType, offset + parse.getSpan().getStart(), offset + parse.getSpan().getEnd()); parseAnnotation.setStringValue(mTypeFeature, parse.getType()); if (probabilityFeature != null) { parseAnnotation.setDoubleValue(probabilityFeature, parse.getProb()); } ArrayFS childrenArray = cas.createArrayFS(parseChildAnnotations.length); childrenArray.copyFromArray(parseChildAnnotations, 0, 0, parseChildAnnotations.length); parseAnnotation.setFeatureValue(childrenFeature, childrenArray); cas.getIndexRepository().addFS(parseAnnotation); return parseAnnotation; }
public static ArrayFS createArrayFS(CAS aCas, Collection<? extends FeatureStructure> aCollection) { return fillArrayFS(aCas.createArrayFS(aCollection.size()), aCollection); }
public static ArrayFS createArrayFS(CAS aCas, FeatureStructure[] aArray) { return fillArrayFS(aCas.createArrayFS(aArray.length), asList(aArray)); }
/** * update a base annotation with slot annotations * * @param linkFSesPerAnno * contains list of slot annotations per a base annotation * @param aLinkeF * The link slot annotation feature */ private void addSlotAnnotations(Map<AnnotationFS, List<FeatureStructure>> linkFSesPerAnno, Feature aLinkeF) { for (AnnotationFS anno : linkFSesPerAnno.keySet()) { ArrayFS array = anno.getCAS().createArrayFS(linkFSesPerAnno.get(anno).size()); array.copyFromArray( linkFSesPerAnno.get(anno) .toArray(new FeatureStructure[linkFSesPerAnno.get(anno).size()]), 0, 0, linkFSesPerAnno.get(anno).size()); anno.setFeatureValue(aLinkeF, array); anno.getCAS().addFsToIndexes(anno); } }
/** * update a base annotation with slot annotations * * @param linkFSesPerAnno * contains list of slot annotations per a base annotation * @param aLinkeF * The link slot annotation feature */ private void addSlotAnnotations(Map<AnnotationFS, List<FeatureStructure>> linkFSesPerAnno, Feature aLinkeF) { for (AnnotationFS anno : linkFSesPerAnno.keySet()) { ArrayFS array = anno.getCAS().createArrayFS(linkFSesPerAnno.get(anno).size()); array.copyFromArray( linkFSesPerAnno.get(anno).toArray(new FeatureStructure[linkFSesPerAnno.get(anno).size()]), 0, 0, linkFSesPerAnno.get(anno).size()); anno.setFeatureValue(aLinkeF, array); anno.getCAS().addFsToIndexes(anno); } }
public static void setLinkFeatureValue(FeatureStructure aFS, Feature aFeature, List<FeatureStructure> linkFSes) { // Create a new array if size differs otherwise re-use existing one ArrayFS array = (ArrayFS) WebAnnoCasUtil.getFeatureFS(aFS, aFeature.getShortName()); if (array == null || (array.size() != linkFSes.size())) { array = aFS.getCAS().createArrayFS(linkFSes.size()); } // Fill in links array.copyFromArray(linkFSes.toArray(new FeatureStructure[linkFSes.size()]), 0, 0, linkFSes.size()); aFS.setFeatureValue(aFeature, array); }
/** * update a base annotation with slot annotations * * @param linkFSesPerAnno * contains list of slot annotations per a base annotation * @param aLinkeF * The link slot annotation feature */ private void addSlotAnnotations(Map<AnnotationFS, List<FeatureStructure>> linkFSesPerAnno, Feature aLinkeF) { for (AnnotationFS anno : linkFSesPerAnno.keySet()) { ArrayFS array = anno.getCAS().createArrayFS(linkFSesPerAnno.get(anno).size()); array.copyFromArray( linkFSesPerAnno.get(anno) .toArray(new FeatureStructure[linkFSesPerAnno.get(anno).size()]), 0, 0, linkFSesPerAnno.get(anno).size()); anno.setFeatureValue(aLinkeF, array); anno.getCAS().addFsToIndexes(anno); } }
public static void setLinkFeatureValue(FeatureStructure aFS, Feature aFeature, List<FeatureStructure> linkFSes) { // Create a new array if size differs otherwise re-use existing one ArrayFS array = (ArrayFS) WebAnnoCasUtil.getFeatureFS(aFS, aFeature.getShortName()); if (array == null || (array.size() != linkFSes.size())) { array = aFS.getCAS().createArrayFS(linkFSes.size()); } // Fill in links array.copyFromArray(linkFSes.toArray(new FeatureStructure[linkFSes.size()]), 0, 0, linkFSes.size()); aFS.setFeatureValue(aFeature, array); }
public static FeatureStructure toCompatibleCollection(CAS cas, Feature targetFeat, Collection<? extends FeatureStructure> srcCol) { if (srcCol == null) { return null; } // TODO handle lists if (targetFeat.getRange().isArray()) { ArrayFS result = cas.createArrayFS(srcCol.size()); int i = 0; for (FeatureStructure elemFS : srcCol) { result.set(i, elemFS); i++; } return result; } else { throw new UnsupportedOperationException(); } }
ArrayFS array = baseFs.getCAS().createArrayFS(linkFSes.size()); array.copyFromArray(linkFSes.toArray(new FeatureStructure[linkFSes.size()]), 0, 0, linkFSes.size());
ArrayFS array = baseFs.getCAS().createArrayFS(linkFSes.size()); array.copyFromArray(linkFSes.toArray(new FeatureStructure[linkFSes.size()]), 0, 0, linkFSes.size());
FeatureStructure newFeatureFS = null; if (oldRange.isArray()) { newFeatureFS = cas.createArrayFS(0); } else { newFeatureFS = cas.createFS(feature.getRange());
FeatureStructure newFeatureFS = null; if (oldRange.isArray()) { newFeatureFS = cas.createArrayFS(0); } else { newFeatureFS = cas.createFS(feature.getRange());
fs = document.getCAS().createStringArrayFS(arraySize); } else if (type.getName().equals(CAS.TYPE_NAME_FS_ARRAY)) { fs = document.getCAS().createArrayFS(arraySize); } else { throw new CasEditorError("Unkown array type: " + type.getName() + "!");
ArrayFS array = cas.createArrayFS(1); FeatureStructure linkFS = cas.createFS(linkType); FSUtil.setFeature(linkFS, feat1.getLinkTypeRoleFeatureName(), "role");
protected AnnotationFS createAnnotation(CAS cas, int offset, Parse parse) { Parse[] parseChildren = parse.getChildren(); AnnotationFS[] parseChildAnnotations = new AnnotationFS[parseChildren.length]; // do this for all children for (int i = 0; i < parseChildren.length; i++) { parseChildAnnotations[i] = createAnnotation(cas, offset, parseChildren[i]); } AnnotationFS parseAnnotation = cas.createAnnotation(mParseType, offset + parse.getSpan().getStart(), offset + parse.getSpan().getEnd()); parseAnnotation.setStringValue(mTypeFeature, parse.getType()); if (probabilityFeature != null) { parseAnnotation.setDoubleValue(probabilityFeature, parse.getProb()); } ArrayFS childrenArray = cas.createArrayFS(parseChildAnnotations.length); childrenArray.copyFromArray(parseChildAnnotations, 0, 0, parseChildAnnotations.length); parseAnnotation.setFeatureValue(childrenFeature, childrenArray); cas.getIndexRepository().addFS(parseAnnotation); return parseAnnotation; }
ArrayFS arrayFs = (ArrayFS) aSrcFs; int len = arrayFs.size(); ArrayFS destFS = mDestCas.createArrayFS(len); for (int i = 0; i < len; i++) { FeatureStructure srcElem = arrayFs.get(i);