private String serializeTypeSystem(CAS aCas) throws RecommendationException { try (StringWriter out = new StringWriter()) { TypeSystemUtil.typeSystem2TypeSystemDescription(aCas.getTypeSystem()).toXML(out); return out.toString(); } catch (CASRuntimeException | SAXException | IOException e) { throw new RecommendationException("Coud not serialize type system", e); } }
/** * Convert a {@link TypeSystem} to an equivalent {@link TypeSystemDescription}. * * @param aTypeSystem * type system object to convert * @return a TypeSystemDescription that is equivalent to <code>aTypeSystem</code> */ public static TypeSystemDescription typeSystem2TypeSystemDescription(TypeSystem aTypeSystem) { ResourceSpecifierFactory fact = UIMAFramework.getResourceSpecifierFactory(); TypeSystemDescription tsDesc = fact.createTypeSystemDescription(); Iterator<Type> typeIter = aTypeSystem.getTypeIterator(); ArrayList<TypeDescription> typeDescs = new ArrayList<TypeDescription>(); while (typeIter.hasNext()) { Type type = typeIter.next(); if (!type.getName().startsWith("uima.cas") && !type.getName().equals("uima.tcas.Annotation") && !type.isArray()) { typeDescs.add(type2TypeDescription(type, aTypeSystem)); } } TypeDescription[] typeDescArr = new TypeDescription[typeDescs.size()]; typeDescs.toArray(typeDescArr); tsDesc.setTypes(typeDescArr); return tsDesc; }
String[] allowedValues = getAllowedValuesForType(aType, aTypeSystem); AllowedValue[] avObjs = new AllowedValue[allowedValues.length]; for (int i = 0; i < allowedValues.length; i++) { for (Feature feat : aType.getFeatures()){ if (!superType.getFeatures().contains(feat)) { featDescs.add(feature2FeatureDescription(feat));
private String serializeTypeSystem(CAS aCas) throws RecommendationException { try (StringWriter out = new StringWriter()) { TypeSystemUtil.typeSystem2TypeSystemDescription(aCas.getTypeSystem()).toXML(out); return out.toString(); } catch (CASRuntimeException | SAXException | IOException e) { throw new RecommendationException("Coud not serialize type system", e); } }
/** * Writes "typesystem.xml" to the output tar.gz * * @param aJCas any jcas from the collection to get the currently active typesystem * @throws IOException IO Exception */ private void writeTypeSystem(JCas aJCas) throws IOException { try { String name = "typesystem.xml"; java.io.ByteArrayOutputStream stream = new java.io.ByteArrayOutputStream(); TypeSystemUtil.typeSystem2TypeSystemDescription(aJCas.getTypeSystem()).toXML(stream); // add to tar addSingleEntryToTar(stream.toByteArray(), name); } catch (SAXException e) { throw new IOException(e); } }
private void writeTypeSystem(JCas aJCas) throws IOException, CASRuntimeException, SAXException { @SuppressWarnings("resource") OutputStream typeOS = null; try { if (typeSystemFile != null) { typeOS = CompressionUtils.getOutputStream(typeSystemFile); } else { typeOS = getOutputStream("TypeSystem", ".xml"); } TypeSystemUtil.typeSystem2TypeSystemDescription(aJCas.getTypeSystem()).toXML(typeOS); } finally { closeQuietly(typeOS); } } }
private void writeTypeSystem(JCas aJCas) throws IOException, CASRuntimeException, SAXException { @SuppressWarnings("resource") OutputStream typeOS = null; try { if (typeSystemFile != null) { typeOS = CompressionUtils.getOutputStream(typeSystemFile); } else { typeOS = getOutputStream("TypeSystem", ".xml"); } TypeSystemUtil.typeSystem2TypeSystemDescription(aJCas.getTypeSystem()).toXML(typeOS); } finally { closeQuietly(typeOS); } } }
private void writeTypeSystem(JCas aJCas) throws IOException, CASRuntimeException, SAXException { @SuppressWarnings("resource") OutputStream typeOS = null; try { if (typeSystemFile != null) { typeOS = CompressionUtils.getOutputStream(typeSystemFile); } else { typeOS = getOutputStream("typesystem", ".xml"); } TypeSystemUtil.typeSystem2TypeSystemDescription(aJCas.getTypeSystem()).toXML(typeOS); } finally { closeQuietly(typeOS); } } }
private void writeTypeSystem(JCas aJCas) throws IOException, CASRuntimeException, SAXException { @SuppressWarnings("resource") OutputStream typeOS = null; try { if (typeSystemFile != null) { typeOS = CompressionUtils.getOutputStream(typeSystemFile); } else { typeOS = getOutputStream("TypeSystem", ".xml"); } TypeSystemUtil.typeSystem2TypeSystemDescription(aJCas.getTypeSystem()).toXML(typeOS); } finally { closeQuietly(typeOS); } } }
private void writeTypeSystem(JCas aJCas) throws IOException, CASRuntimeException, SAXException { @SuppressWarnings("resource") OutputStream typeOS = null; try { if (typeSystemFile != null) { typeOS = CompressionUtils.getOutputStream(typeSystemFile); } else { typeOS = getOutputStream("TypeSystem", ".xml"); } TypeSystemUtil.typeSystem2TypeSystemDescription(aJCas.getTypeSystem()).toXML(typeOS); } finally { closeQuietly(typeOS); } } }
private void writeTypeSystem(JCas aJCas) throws IOException, CASRuntimeException, SAXException { @SuppressWarnings("resource") OutputStream typeOS = null; try { if (typeSystemFile != null) { typeOS = CompressionUtils.getOutputStream(typeSystemFile); } else { typeOS = getOutputStream("typesystem", ".xml"); } TypeSystemUtil.typeSystem2TypeSystemDescription(aJCas.getTypeSystem()).toXML(typeOS); } finally { closeQuietly(typeOS); } } }
private void writeTypeSystem(JCas aJCas) throws IOException, CASRuntimeException, SAXException { @SuppressWarnings("resource") OutputStream typeOS = null; try { if (typeSystemFile != null) { typeOS = CompressionUtils.getOutputStream(typeSystemFile); } else { typeOS = getOutputStream("typesystem", ".xml"); } TypeSystemUtil.typeSystem2TypeSystemDescription(aJCas.getTypeSystem()).toXML(typeOS); } finally { closeQuietly(typeOS); } } }
TypeSystemDescription tsd = TypeSystemUtil.typeSystem2TypeSystemDescription(cas.getTypeSystem()); File tsd2xml = new File(((String)casLogDirMap.get(analysisEngineKey))+"/typesystem.xml"); FileOutputStream os = new FileOutputStream(tsd2xml);
List<TypeSystemDescription> tsds = new ArrayList<>(); if (mergeTypeSystem) { tsds.add(TypeSystemUtil.typeSystem2TypeSystemDescription(aCAS.getTypeSystem()));