private Set<String> getTypes(URL resource, ResourceManager resMgr) throws IOException, InvalidXMLException { Set<String> types = new HashSet<String>(); TypeSystemDescription typeSysDescr = null; typeSysDescr = UIMAFramework.getXMLParser().parseTypeSystemDescription( new XMLInputSource(resource)); typeSysDescr.resolveImports(resMgr); for (TypeDescription each : typeSysDescr.getTypes()) { String name = each.getName(); String[] nameSpace = name.split("[.]"); types.add(nameSpace[nameSpace.length - 1]); StringBuffer fullName = new StringBuffer(); if (nameSpace.length > 0) { fullName.append(nameSpace[0]); } for (int i = 1; i < nameSpace.length; i++) { // TODO fix workaround if (!nameSpace[i].equals("type")) { fullName.append('.'); fullName.append(nameSpace[i]); } } types.add(fullName.toString()); } return types; }
private void getTypesystem() throws AnalysisEngineProcessException { byte[] buff = new byte[10000]; int bytesread; ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { while (-1 != (bytesread = zis.read(buff))) { baos.write(buff, 0, bytesread); } ByteArrayInputStream bis = new ByteArrayInputStream(baos.toByteArray()); // Get XML parser from framework XMLParser xmlParser = UIMAFramework.getXMLParser(); // Parse type system descriptor TypeSystemDescription tsDesc = xmlParser .parseTypeSystemDescription(new XMLInputSource((InputStream) bis, null)); // Use type system description to create CAS and get the type system // object inputTS = CasCreationUtils.createCas(tsDesc, null, null).getTypeSystem(); // advance to first input CAS nextEntry = zis.getNextEntry(); } catch (Exception e) { throw new AnalysisEngineProcessException(e); } }
/** * Creates a {@link TypeSystemDescription} from all type descriptions that can be found via the * default import pattern or via the {@code META-INF/org.apache.uima.fit/types.txt} files in the * classpath. * * @return the auto-scanned type system. * @throws ResourceInitializationException * if the collected type system descriptions cannot be merged. */ public static TypeSystemDescription createTypeSystemDescription() throws ResourceInitializationException { List<TypeSystemDescription> tsdList = new ArrayList<TypeSystemDescription>(); for (String location : scanTypeDescriptors()) { try { XMLInputSource xmlInputType1 = new XMLInputSource(location); tsdList.add(getXMLParser().parseTypeSystemDescription(xmlInputType1)); LogFactory.getLog(TypeSystemDescription.class).debug( "Detected type system at [" + location + "]"); } catch (IOException e) { throw new ResourceInitializationException(e); } catch (InvalidXMLException e) { LogFactory.getLog(TypeSystemDescription.class).warn( "[" + location + "] is not a type file. Ignoring.", e); } } ResourceManager resMgr = ResourceManagerFactory.newResourceManager(); return mergeTypeSystems(tsdList, resMgr); }
@Override protected String getDescriptionFromImport(String source) throws InvalidXMLException, IOException { TypeSystemDescription parsedImportItem = UIMAFramework.getXMLParser() .parseTypeSystemDescription(new XMLInputSource(source)); return parsedImportItem.getDescription(); }
private void resolveImport(URL aURL, Collection<String> aAlreadyImportedTypeSystemURLs, Collection<TypeDescription> aResults, ResourceManager aResourceManager) throws InvalidXMLException, IOException { //check the import cache TypeSystemDescription desc; String urlString = aURL.toString(); Map<String, XMLizable> importCache = ((ResourceManager_impl)aResourceManager).getImportCache(); Map<String, Set<String>> importUrlsCache = ((ResourceManager_impl)aResourceManager).getImportUrlsCache(); synchronized(importCache) { XMLizable cachedObject = importCache.get(urlString); if (cachedObject instanceof TypeSystemDescription) { desc = (TypeSystemDescription)cachedObject; // Add the URLs parsed for this cached object to the list already-parsed (UIMA-5058) aAlreadyImportedTypeSystemURLs.addAll(importUrlsCache.get(urlString)); } else { XMLInputSource input; input = new XMLInputSource(aURL); desc = UIMAFramework.getXMLParser().parseTypeSystemDescription(input); TreeSet<String> previouslyImported = new TreeSet<String>(aAlreadyImportedTypeSystemURLs); desc.resolveImports(aAlreadyImportedTypeSystemURLs, aResourceManager); importCache.put(urlString, desc); // Save the URLS parsed by this import TreeSet<String> locallyImported = new TreeSet<String>(aAlreadyImportedTypeSystemURLs); locallyImported.removeAll(previouslyImported); importUrlsCache.put(urlString, locallyImported); } } aResults.addAll(Arrays.asList(desc.getTypes())); }
private TypeSystemDescription getTypeSystemDescriptor(URL url, RutaBuildOptions option, ResourceManager rm) throws InvalidXMLException, IOException { TypeSystemDescription tsdesc = UIMAFramework.getXMLParser() .parseTypeSystemDescription(new XMLInputSource(url)); if (option.isResolveImports()) { tsdesc.resolveImports(rm); } return tsdesc; }
private TypeSystemDescription getLocalTSD(String toLoad) throws InvalidXMLException, IOException { TypeSystemDescription localTSD = localTSDMap.get(toLoad); if (localTSD == null) { String locateTSD = locate(toLoad, descriptorPaths, "TypeSystem.xml", true); if (locateTSD != null) { localTSD = UIMAFramework.getXMLParser().parseTypeSystemDescription( new XMLInputSource(locateTSD)); ResourceManager resMgr = UIMAFramework.newDefaultResourceManager(); resMgr.setDataPath(getDataPath()); localTSD.resolveImports(resMgr); localTSDMap.put(toLoad, localTSD); } } return localTSD; }
UIMAFramework .getXMLParser() .parseTypeSystemDescription( new XMLInputSource( this.getClass()
if (descriptorPath.toFile().exists()) { typeSysDescr = UIMAFramework.getXMLParser() .parseTypeSystemDescription(new XMLInputSource(descriptorPath.toPortableString())); ResourceManager resMgr = getResourceManager(classLoader); typeSysDescr.resolveImports(resMgr); if (resources != null && resources.length != 0) { typeSysDescr = UIMAFramework.getXMLParser() .parseTypeSystemDescription(new XMLInputSource(resources[0].getURL())); ResourceManager resMgr = getResourceManager(classLoader); typeSysDescr.resolveImports(resMgr);
try { xmlParser.parseTypeSystemDescription(xmlSource); uimaCompCtg = TYPE_SYSTEM_CTG; __errTableByUri.remove( xmlDescUri );
if (path != null) { tsDesc = UIMAFramework.getXMLParser() .parseTypeSystemDescription(new XMLInputSource(path.toFile())); } else { tsDesc = UIMAFramework.getXMLParser().parseTypeSystemDescription(new XMLInputSource(url));
.parseTypeSystemDescription(new XMLInputSource(typeSystemFile))); TypeSystemDescription merged = CasCreationUtils.mergeTypeSystems(tsds);
.parseTypeSystemDescription(new XMLInputSource(defaultTypeSystem)); CAS cas = CasCreationUtils.createCas(initialTypeSystem, null, new FsIndexDescription[0]); fillTypeNameMap(typeNameMap, cas.getTypeSystem());
TypeSystemDescription tsDescription = UIMAFramework.getXMLParser().parseTypeSystemDescription( xmlIn);
.parseTypeSystemDescription(new XMLInputSource(aIS, null)); TypeSystemAnalysis analysis = TypeSystemAnalysis.of(tsd); for (AnnotationLayer l : analysis.getLayers()) {
.parseTypeSystemDescription(new XMLInputSource(aIS, null)); TypeSystemAnalysis analysis = TypeSystemAnalysis.of(tsd); for (AnnotationLayer l : analysis.getLayers()) {