private Type getType(String name, CAS cas) { String typeName = HtmlAnnotator.NAMESPACE + name; Type type = cas.getTypeSystem().getType(typeName); if (type == null) { type = cas.getTypeSystem().getType(HtmlAnnotator.NAMESPACE + "TAG"); } return type; }
private Type getType(String name, CAS cas) { String typeName = HtmlAnnotator.NAMESPACE + name; Type type = cas.getTypeSystem().getType(typeName); if (type == null) { type = cas.getTypeSystem().getType(HtmlAnnotator.NAMESPACE + "TAG"); } return type; }
/** * Helper to get the test type, e.g. org.apache.uima.T1, org.apache.uima.T2, ... * * @param cas - The CAS object containing the type system * @param i - typeId, converted to {@link #TYPE} + i * @return the test type object with the given counter */ public static Type getTestType(CAS cas, int i) { if (cas == null) return null; return cas.getTypeSystem().getType(TYPE + i); }
/** * Checks it the type system of the given CAS is different from the last type system this * component was operating on. If it is different, calls the typeSystemInit method on the * component. */ private void checkTypeSystemChange(CAS aCAS) throws AnalysisEngineProcessException { TypeSystem typeSystem = aCAS.getTypeSystem(); if (typeSystem != mLastTypeSystem) { typeSystemInit(typeSystem); mLastTypeSystem = typeSystem; } }
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; } }
public Feature getFeature(AnnotationFS annotation) { if(f==null) { /* * TODO Ensure that the Feature will be reset for a new TypeSystem */ f = annotation.getCAS().getTypeSystem().getFeatureByFullName(feature); } return f; }
/** * Gets the types. * * @return the types */ private Type[] getTypes() { TypeSystem typeSystem = editor.getDocument().getCAS().getTypeSystem(); List<Type> types = typeSystem.getProperlySubsumedTypes(typeSystem.getType(CAS.TYPE_NAME_ANNOTATION)); types.add(typeSystem.getType(CAS.TYPE_NAME_ANNOTATION)); return types.toArray(new Type[types.size()]); }
public static Set<FeatureStructure> getNonIndexedFSes(CAS aCas) { TypeSystem ts = aCas.getTypeSystem(); Set<FeatureStructure> allIndexedFS = collectIndexed(aCas); Set<FeatureStructure> allReachableFS = collectReachable(aCas); // Remove all that are indexed allReachableFS.removeAll(allIndexedFS); // Remove all that are not annotations allReachableFS.removeIf(fs -> !ts.subsumes(aCas.getAnnotationType(), fs.getType())); // All that is left are non-index annotations return allReachableFS; }
public static Set<FeatureStructure> collectIndexed(CAS aCas) { LowLevelCAS llcas = aCas.getLowLevelCAS(); Set<FeatureStructure> fses = new TreeSet<>((fs1, fs2) -> llcas.ll_getFSRef(fs1) - llcas.ll_getFSRef(fs2)); FSIterator<FeatureStructure> i = aCas.getIndexRepository().getAllIndexedFS( aCas.getTypeSystem().getTopType()); i.forEachRemaining(fs -> fses.add(fs)); return fses; }
public static Set<FeatureStructure> collectIndexed(CAS aCas) { LowLevelCAS llcas = aCas.getLowLevelCAS(); Set<FeatureStructure> fses = new TreeSet<>((fs1, fs2) -> llcas.ll_getFSRef(fs1) - llcas.ll_getFSRef(fs2)); FSIterator<FeatureStructure> i = aCas.getIndexRepository().getAllIndexedFS( aCas.getTypeSystem().getTopType()); i.forEachRemaining(fs -> fses.add(fs)); return fses; }
@Override public void write(OutputStream aStream) throws Exception { XmiCasSerializer ser = new XmiCasSerializer(cas.getTypeSystem()); XMLSerializer xmlSer = new XMLSerializer(aStream, false); ser.serialize(cas, xmlSer.getContentHandler()); }
@Override public void write(OutputStream aStream) throws Exception { XmiCasSerializer ser = new XmiCasSerializer(cas.getTypeSystem()); XMLSerializer xmlSer = new XMLSerializer(aStream, false); ser.serialize(cas, xmlSer.getContentHandler()); }
private void removePartOf(int code) { if (partOf[code] != 0) { partOf[code] = partOf[code] - 1; if (!lowMemoryProfile) { int parentCode = getCAS().getTypeSystem().getLowLevelTypeSystem().ll_getParentType(code); if (parentCode > 0) { removePartOf(parentCode); } } } }
private void writeXmi(CAS aCas, OutputStream out) throws IOException, SAXException { // seems like it is not necessary to buffer outputStream for SAX TransformationHandler // out = new BufferedOutputStream(out); XmiCasSerializer ser = new XmiCasSerializer(aCas.getTypeSystem()); XMLSerializer xmlSer = new XMLSerializer(out, xmlFormatted); ser.serialize(aCas, xmlSer.getContentHandler()); } }
private void insertFS(FeatureStructure fs, Type type, CAS cas, boolean withParents) { TypeTreeNode typeTreeNode = getTreeNode(type, cas); FSTreeNode node = createFSNode(typeTreeNode, fs); typeTreeNode.addChild(node); if (withParents) { Type parent = fs.getCAS().getTypeSystem().getParent(type); if (parent != null) { insertFS(fs, parent, cas, withParents); } } }
public static FeatureStructure getTcasFS(CAS aCasView, String aTypeS) { org.apache.uima.cas.FeatureStructure idFS = null; Type type = aCasView.getTypeSystem().getType(aTypeS); if (type != null) { FSIterator<AnnotationFS> idIter = aCasView.getAnnotationIndex(type).iterator(); while (idIter.isValid()) { idFS = idIter.get(); idIter.moveToNext(); } } return idFS; }
private void addTCSequenceAnnotation(JCas jcas) { Type type = jcas.getCas().getTypeSystem().getType(nameSequence); Collection<AnnotationFS> sequenceAnnotation = CasUtil.select(jcas.getCas(), type); for (AnnotationFS seq : sequenceAnnotation) { TextClassificationSequence tcs = new TextClassificationSequence(jcas, seq.getBegin(), seq.getEnd()); tcs.addToIndexes(); } }
private void addTCSequenceAnnotation(JCas jcas) { Type type = jcas.getCas().getTypeSystem().getType(nameSequence); Collection<AnnotationFS> sequenceAnnotation = CasUtil.select(jcas.getCas(), type); for (AnnotationFS seq : sequenceAnnotation) { TextClassificationSequence tcs = new TextClassificationSequence(jcas, seq.getBegin(), seq.getEnd()); tcs.addToIndexes(); } }
private void addTCSequenceAnnotation(JCas jcas) { Type type = jcas.getCas().getTypeSystem().getType(sequenceName); Collection<AnnotationFS> sequenceAnnotation = CasUtil.select(jcas.getCas(), type); for (AnnotationFS seq : sequenceAnnotation) { TextClassificationSequence tcs = new TextClassificationSequence(jcas, seq.getBegin(), seq.getEnd()); tcs.addToIndexes(); } }