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); }
.createAnnotation(tokenType, sentenceOffset + tokenSpans[i].getStart(), sentenceOffset + tokenSpans[i].getEnd());
@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); } }
nameAnnotations[i] = cas.createAnnotation(nameType, startIndex, endIndex); cas.getIndexRepository().addFS(nameAnnotations[i]);
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; }
sentences[i] = cas.createAnnotation(sentenceType, sentPositions[i].getStart() + containerAnnotation.getBegin(), sentPositions[i].getEnd() + containerAnnotation.getBegin());
private void createTokenAnnotation(CAS cas, int start, int end) { AnnotationFS tokenAnno = cas.createAnnotation(tokenType, start, end); cas.addFsToIndexes(tokenAnno); }
public static PredicateTruth mapPredicateTruth(PredTruth pt, JCas jcas, int begin, int end){ Type type = jcas.getTypeSystem().getType(PRED_TRUTH_MAP.get(pt).getName()); PredicateTruth ret = (PredicateTruth)jcas.getCas().createAnnotation(type, begin, end); return ret; }
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 chunkComplete() { if (openChunk != null) { Type chunkType = mappingProvider.getTagType(openChunk); Chunk chunk = (Chunk) cas.createAnnotation(chunkType, start, end); chunk.setChunkValue(openChunk.intern()); 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 POS createPartOfSpeechAnnotationFromOutcome(JCas aJCas, int begin, int end, String aOutcome) { Type posTag = mappingProvider.getTagType(aOutcome); POS posAnno = (POS) aJCas.getCas().createAnnotation(posTag, begin, end); posAnno.setPosValue(aOutcome); posAnno.addToIndexes(); return posAnno; }
public TextMarkerBasic getNextBasic2(AnnotationFS previous) { AnnotationFS pointer = cas .createAnnotation(basicType, previous.getEnd() - 1, previous.getEnd()); currentIt.moveTo(pointer); if (currentIt.isValid()) { TextMarkerBasic basic = (TextMarkerBasic) currentIt.get(); return basic; } return null; }
/** * 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; }
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; }
private static AnnotationFS makeLinkHostFS(JCas aJCas, String aType, int aBegin, int aEnd, FeatureStructure... aLinks) { Type hostType = aJCas.getTypeSystem().getType(aType); AnnotationFS hostA1 = aJCas.getCas().createAnnotation(hostType, aBegin, aEnd); if (aLinks != null) { hostA1.setFeatureValue(hostType.getFeatureByBaseName("links"), FSCollectionFactory.createFSArray(aJCas, asList(aLinks))); } aJCas.getCas().addFsToIndexes(hostA1); return hostA1; }
public static void makeLinkHostFS(JCas aJCas, int aBegin, int aEnd, 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))); aJCas.getCas().addFsToIndexes(hostA1); }