protected void documentDone(CAS cas) { // TODO: Create confidence FS // contains String name type // contains Double prob if (documentConfidenceType != null) { FeatureStructure confidenceFS = cas.createFS(documentConfidenceType); confidenceFS.setDoubleValue(documentConfidenceFeature, documentConfidence.mean()); confidenceFS.setStringValue(documentConfidenceNameTypeFeature, mNameType.getName()); cas.addFsToIndexes(confidenceFS); } // Clears the adaptive data which was created for the current document mNameFinder.clearAdaptiveData(); documentConfidence = new Mean(); }
@Override public boolean containsKey(Object key) { if (!(key instanceof String)) { return false; } FeatureStructure check = metadataCas.createFS(metadataType); check.setStringValue(keyFeature, (String) key); return metadataIndex.contains(check); } }
@Nullable @Override public String get(Object key) { if (!(key instanceof String)) { return null; } FeatureStructure check = metadataCas.createFS(metadataType); check.setStringValue(keyFeature, (String) key); FeatureStructure fs = metadataIndex.find(check); return fs.getStringValue(valueFeature); }
public static <T extends TOP> T createFeatureStructure(JCas jcas, Class<T> cls) { T fs = jcas.getCas().createFS(JCasUtil.getType(jcas, cls)); fs.addToIndexes(); return fs; }
@Override public void run() { // TODO: check if an AnnotationFS was created, if so // add it to the document // inserts a new feature structure of current type if (mCurrentType == null) { return; } FeatureStructure newFeatureStructure = mDocument.getCAS().createFS(mCurrentType); mDocument.addFeatureStructure(newFeatureStructure); mFSList.refresh(); } }
/** * Function for creating generic UIMA {@code FeatureStructure}s. * * @param featureStructure {@code FeatureStructure} to create a new object of the same type in the * target cas. * @return newly created {@code FeatureStructure} matching the type of the parameter {@code * FeatureStructure} */ private FeatureStructure defaultCreateType(FeatureStructure featureStructure) { String typeName = featureStructure.getType().getName(); Type targetType = targetCas.getTypeSystem().getType(typeName); return targetCas.createFS(targetType); }
public static <T extends TOP> T getOrCreate(JCas jcas, Class<T> targetClass) { if (JCasUtil.exists(jcas, targetClass)) { return JCasUtil.selectSingle(jcas, targetClass); } else { T annotation = (T) jcas.getCas().createFS(JCasUtil.getType(jcas, targetClass)); jcas.getCas().addFsToIndexes(annotation); return annotation; } } }
/** * Create a new chain head feature structure. Already adds the chain to the CAS. */ private FeatureStructure newChain(JCas aJCas, AnnotationFS aFirstLink) { Type chainType = getAnnotationType(aJCas.getCas()); FeatureStructure newChain = aJCas.getCas().createFS(chainType); newChain.setFeatureValue(chainType.getFeatureByBaseName(chainFirstFeatureName), aFirstLink); aJCas.addFsToIndexes(newChain); return newChain; }
public static <T extends TOP> T getOrCreate(JCas jcas, Class<T> targetClass) { if (JCasUtil.exists(jcas, targetClass)) { return JCasUtil.selectSingle(jcas, targetClass); } else { T annotation = jcas.getCas().createFS(JCasUtil.getType(jcas, targetClass)); jcas.getCas().addFsToIndexes(annotation); return annotation; } } }
public static <T extends TOP> T getOrCreate(JCas jcas, Class<T> targetClass) { if (JCasUtil.exists(jcas, targetClass)) { return JCasUtil.selectSingle(jcas, targetClass); } else { T annotation = jcas.getCas().createFS(JCasUtil.getType(jcas, targetClass)); jcas.getCas().addFsToIndexes(annotation); return annotation; } } }
public Object clone() throws CASRuntimeException { if (getType().getName().equals(CAS.TYPE_NAME_SOFA)) { throw new CASRuntimeException(CASRuntimeException.CANNOT_CLONE_SOFA); } CASImpl casImpl = this.getCASImpl(); FeatureStructure newFS = getCAS().createFS(getType()); casImpl.copyFeatures(((FeatureStructureImpl) newFS).getAddress(), this.getAddress()); return newFS; }
private static void makeChainHead(Type aType, AnnotationFS first) { CAS cas = first.getCAS(); FeatureStructure h = cas.createFS(aType); FSUtil.setFeature(h, "first", first); cas.addFsToIndexes(h); }
/** * 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; }
protected void documentDone(CAS cas) { // TODO: Create confidence FS // contains String name type // contains Double prob if (documentConfidenceType != null) { FeatureStructure confidenceFS = cas.createFS(documentConfidenceType); confidenceFS.setDoubleValue(documentConfidenceFeature, documentConfidence.mean()); confidenceFS.setStringValue(documentConfidenceNameTypeFeature, mNameType.getName()); cas.addFsToIndexes(confidenceFS); } // Clears the adaptive data which was created for the current document mNameFinder.clearAdaptiveData(); documentConfidence = new Mean(); }
/** * 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; }
@Override public void execute(MatchContext context, RutaStream stream, InferenceCrowd crowd) { RuleElement element = context.getElement(); Type casType = stream.getJCas().getCasType(RutaColoring.type); FeatureStructure newAnnotationFS = stream.getCas().createFS(casType); RutaColoring coloring = null; if (newAnnotationFS instanceof RutaColoring) { coloring = (RutaColoring) newAnnotationFS; element.getParent(); coloring.setBgColor(bgcolor.getStringValue(context, stream)); coloring.setFgColor(fgcolor.getStringValue(context, stream)); coloring.setSelected(selected.getBooleanValue(context, stream)); coloring.setTargetType(type.getType(context, stream).getName()); coloring.addToIndexes(); } }
@Override public void execute(RuleMatch match, RuleElement element, TextMarkerStream stream, InferenceCrowd crowd) { Type casType = stream.getJCas().getCasType(TextMarkerColoring.type); FeatureStructure newAnnotationFS = stream.getCas().createFS(casType); TextMarkerColoring coloring = null; if (newAnnotationFS instanceof TextMarkerColoring) { coloring = (TextMarkerColoring) newAnnotationFS; coloring.setBgColor(bgcolor.getStringValue(element.getParent())); coloring.setFgColor(fgcolor.getStringValue(element.getParent())); coloring.setSelected(selected.getBooleanValue(element.getParent())); coloring.setTargetType(type.getType(element.getParent()).getName()); coloring.addToIndexes(); } }
private static FeatureStructure makeLinkFS(JCas aJCas, String aType, String aSlotLabel, AnnotationFS aTarget) { Type linkType = aJCas.getTypeSystem().getType(aType); FeatureStructure linkA1 = aJCas.getCas().createFS(linkType); linkA1.setStringValue(linkType.getFeatureByBaseName("role"), aSlotLabel); linkA1.setFeatureValue(linkType.getFeatureByBaseName("target"), aTarget); aJCas.getCas().addFsToIndexes(linkA1); return linkA1; }
public static FeatureStructure makeLinkFS(JCas aJCas, String aSlotLabel, int aTargetBegin, int aTargetEnd) { Token token1 = new Token(aJCas, aTargetBegin, aTargetEnd); token1.addToIndexes(); Type linkType = aJCas.getTypeSystem().getType(LINK_TYPE); FeatureStructure linkA1 = aJCas.getCas().createFS(linkType); linkA1.setStringValue(linkType.getFeatureByBaseName("role"), aSlotLabel); linkA1.setFeatureValue(linkType.getFeatureByBaseName("target"), token1); aJCas.getCas().addFsToIndexes(linkA1); return linkA1; } }
public static FeatureStructure makeLinkFS(JCas aJCas, String aSlotLabel, int aTargetBegin, int aTargetEnd) { Token token1 = new Token(aJCas, aTargetBegin, aTargetEnd); token1.addToIndexes(); Type linkType = aJCas.getTypeSystem().getType(LINK_TYPE); FeatureStructure linkA1 = aJCas.getCas().createFS(linkType); linkA1.setStringValue(linkType.getFeatureByBaseName("role"), aSlotLabel); linkA1.setFeatureValue(linkType.getFeatureByBaseName("target"), token1); aJCas.getCas().addFsToIndexes(linkA1); return linkA1; } }