final AnnotationFS tokenAnnotation = sentenceTokenIterator.next(); tokenAnnotation.setStringValue(this.posFeature, posTag);
private void addChunkAnnotation(CAS tcas, AnnotationFS[] tokenAnnotations, String tag, int start, int end) { AnnotationFS chunk = tcas.createAnnotation(mChunkType, tokenAnnotations[start].getBegin(), tokenAnnotations[end - 1].getEnd()); chunk.setStringValue(mChunkFeature, tag); tcas.getIndexRepository().addFS(chunk); }
@Override protected void setBestCategory(CAS tcas, String bestCategory) { FSIndex<AnnotationFS> categoryIndex = tcas.getAnnotationIndex(mCategoryType); AnnotationFS categoryAnnotation; if (categoryIndex.size() > 0) { categoryAnnotation = categoryIndex.iterator().next(); } else { categoryAnnotation = tcas.createAnnotation(mCategoryType, 0, tcas.getDocumentText().length()); tcas.getIndexRepository().addFS(categoryAnnotation); } categoryAnnotation.setStringValue(mCategoryFeature, bestCategory); } }
nameAnnotation.setStringValue(mStructureFeature, text); } else {
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; }
private void chunkComplete() { if (openChunk != null) { Type chunkType = mappingProvider.getTagType(openChunk); AnnotationFS chunk = cas.createAnnotation(chunkType, start, end); chunk.setStringValue(chunkValue, internTags && openChunk != null ? openChunk.intern() : openChunk); cas.addFsToIndexes(chunk); openChunk = null; } } }
private void chunkComplete() { if (openChunk != null) { Type chunkType = mappingProvider.getTagType(openChunk); AnnotationFS chunk = cas.createAnnotation(chunkType, start, end); chunk.setStringValue(chunkValue, internTags && openChunk != null ? openChunk.intern() : openChunk); cas.addFsToIndexes(chunk); openChunk = null; } } }
private void chunkComplete() { if (openChunk != null) { Type chunkType = mappingProvider.getTagType(openChunk); AnnotationFS chunk = cas.createAnnotation(chunkType, start, end); chunk.setStringValue(chunkValue, internTags && openChunk != null ? openChunk.intern() : openChunk); cas.addFsToIndexes(chunk); openChunk = null; } } }
private void chunkComplete() { if (openChunk != null) { Type chunkType = mappingProvider.getTagType(openChunk); AnnotationFS chunk = cas.createAnnotation(chunkType, start, end); chunk.setStringValue(chunkValue, internTags && openChunk != null ? openChunk.intern() : openChunk); cas.addFsToIndexes(chunk); openChunk = null; } } }
private void annotate(CAS cas, Feature feature, int begin, int end, String value) { Type type = feature.getDomain(); AnnotationFS annotation = cas.createAnnotation(type, begin, end); annotation.setStringValue(feature,value); cas.addFsToIndexes(annotation); }
private void setDocumentMetadata(CAS cas, String docName, int docSize) { AnnotationFS docMeta = cas.createAnnotation(documentMetadataType, 0, 0); docMeta.setLongValue(docMetaSizeFeature, docSize); docMeta.setStringValue(docMetaUriFeature, docName); cas.addFsToIndexes(docMeta); }
@Override public void visitRemarkNode(Remark node) { Type type = getType("REMARK", cas); int begin = getBeginOffset(node); int end = getEndOffset(node); AnnotationFS annotation = cas.createAnnotation(type, begin, end); Feature feature = type.getFeatureByBaseName("comment"); annotation.setStringValue(feature, node.getText()); annotations.add(annotation); }
public void visitRemarkNode(Remark node) { Type type = getType("REMARK", cas); int begin = getBeginOffset(node); int end = getEndOffset(node); AnnotationFS annotation = cas.createAnnotation(type, begin, end); Feature feature = type.getFeatureByBaseName("comment"); annotation.setStringValue(feature, node.getText()); annotations.add(annotation); }
@Override public void wroteToDestination(String destinationName, int destinationIndex, TextRange originalDocumentTextLocation) { AnnotationFS viewIndex = originalDocumentView .createAnnotation(viewIndexType, originalDocumentTextLocation.getStartIndex(), originalDocumentTextLocation.getEndIndex()); viewIndex.setStringValue(destinationNameFeature, destinationName); viewIndex.setIntValue(destinationIndexFeature, destinationIndex); originalDocumentView.addFsToIndexes(viewIndex); } }
private void addChunkAnnotation(CAS tcas, AnnotationFS[] tokenAnnotations, String tag, int start, int end) { AnnotationFS chunk = tcas.createAnnotation(mChunkType, tokenAnnotations[start].getBegin(), tokenAnnotations[end - 1].getEnd()); chunk.setStringValue(mChunkFeature, tag); tcas.getIndexRepository().addFS(chunk); }
public static void addSourceDocumentInformation(CAS cas, File each) { Type sdiType = cas.getTypeSystem() .getType("org.apache.uima.examples.SourceDocumentInformation"); if (sdiType != null) { if (cas.getAnnotationIndex(sdiType).size() == 0) { AnnotationFS sdi = cas.createAnnotation(sdiType, cas.getDocumentAnnotation().getBegin(), cas.getDocumentAnnotation().getEnd()); Feature uriFeature = sdiType.getFeatureByBaseName("uri"); sdi.setStringValue(uriFeature, each.toURI().getPath()); cas.addFsToIndexes(sdi); } } }
private AnnotationFS createNEAnno(JCas aJCas, String aValue, int aBegin, int aEnd) { Type type = aJCas.getTypeSystem().getType(NamedEntity.class.getTypeName()); AnnotationFS clickedFs = aJCas.getCas().createAnnotation(type, aBegin, aEnd); Feature value = type.getFeatureByBaseName("value"); clickedFs.setStringValue(value, aValue); aJCas.addFsToIndexes(clickedFs); return clickedFs; }
private AnnotationFS createPOSAnno(JCas aJCas, String aValue, int aBegin, int aEnd) { Type type = aJCas.getTypeSystem().getType(POS.class.getTypeName()); AnnotationFS clickedFs = aJCas.getCas().createAnnotation(type, aBegin, aEnd); Feature posValue = type.getFeatureByBaseName("PosValue"); clickedFs.setStringValue(posValue, aValue); aJCas.addFsToIndexes(clickedFs); return clickedFs; }
public static AnnotationFS makeLinkHostMultiSPanFeatureFS(JCas aJCas, int aBegin, int aEnd, Feature aSpanFeature, String aValue, FeatureStructure... aLinks) { Type hostType = aJCas.getTypeSystem().getType(HOST_TYPE); AnnotationFS hostA1 = aJCas.getCas().createAnnotation(hostType, aBegin, aEnd); hostA1.setFeatureValue(hostType.getFeatureByBaseName("links"), FSCollectionFactory.createFSArray(aJCas, asList(aLinks))); hostA1.setStringValue(aSpanFeature, aValue); aJCas.getCas().addFsToIndexes(hostA1); return hostA1; }
public static AnnotationFS makeLinkHostMultiSPanFeatureFS(JCas aJCas, int aBegin, int aEnd, Feature aSpanFeature, String aValue, FeatureStructure... aLinks) { Type hostType = aJCas.getTypeSystem().getType(HOST_TYPE); AnnotationFS hostA1 = aJCas.getCas().createAnnotation(hostType, aBegin, aEnd); hostA1.setFeatureValue(hostType.getFeatureByBaseName("links"), FSCollectionFactory.createFSArray(aJCas, asList(aLinks))); hostA1.setStringValue(aSpanFeature, aValue); aJCas.getCas().addFsToIndexes(hostA1); return hostA1; }