Refine search
XMLInputSource aeIputSource = new XMLInputSource(aeDescriptorPath); ResourceSpecifier aeSpecifier = UIMAFramework.getXMLParser() .parseResourceSpecifier(aeIputSource); AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(aeSpecifier);
/** * Simple method to load xml description and return an AnalysisEngineDescription object * @param pathToDescription * @return * @throws IOException * @throws InvalidXMLException */ public static AnalysisEngineDescription loadDescription(String pathToDescription) throws IOException, InvalidXMLException { File file = new File(pathToDescription); XMLParser parser = UIMAFramework.getXMLParser(); XMLInputSource source = new XMLInputSource(file); AnalysisEngineDescription desc = parser.parseAnalysisEngineDescription(source); return desc; }
public static FlowControllerDescription getDescription() { URL descUrl = FixedFlowController.class .getResource("/org/apache/uima/flow/FixedFlowController.xml"); FlowControllerDescription desc; try { desc = (FlowControllerDescription) UIMAFramework.getXMLParser().parse( new XMLInputSource(descUrl)); } catch (InvalidXMLException e) { throw new UIMARuntimeException(e); } catch (IOException e) { throw new UIMARuntimeException(e); } return desc; }
public class FetchList extends AsyncTask<Void,Void,Byte>{ @Override protected Byte doInBackground1(Void... arg0){ // this was explained in first step Response res = new Response("url"); String response = res.getResponse(); XMLParser xml = new XMLParser(response); ArrayList<XMLParser> itemList = xml.getItemList(); return xml.parse(); } }
@Override protected String getDescriptionFromImport(String source) throws InvalidXMLException, IOException { TypeSystemDescription parsedImportItem = UIMAFramework.getXMLParser() .parseTypeSystemDescription(new XMLInputSource(source)); return parsedImportItem.getDescription(); }
public static void main(String[] args) throws IOException, UIMAException, CpeDescriptorException { if (args.length != 1) { System.err.println("Usage: <cpeDescriptorPath>"); return; } String cpeDescPath = args[0]; XMLInputSource cpeDescSource = new XMLInputSource(cpeDescPath); CpeDescription cpeDesc = UIMAFramework.getXMLParser().parseCpeDescription(cpeDescSource); // produce CollectionProcessingEngine cpe = UIMAFramework .produceCollectionProcessingEngine(cpeDesc); cpe.addStatusCallbackListener(new ReportingStatusCallbackListener(cpe)); // run cpe.process(); } }
/** * Instantiates a ResourceSpecifier from a given URL. * * @param aDescriptorUrl - URL of descriptor * @return - ResourceSpecifier * * @throws Exception - */ public ResourceSpecifier getSpecifier(URL aDescriptorUrl) throws Exception { XMLInputSource in = new XMLInputSource(aDescriptorUrl); return UIMAFramework.getXMLParser().parseResourceSpecifier(in); }
/** * Parses and returns the descriptor for this collection reader. The descriptor is stored in the * uima.jar file and located using the ClassLoader. * * @return an object containing all of the information parsed from the descriptor. * * @throws InvalidXMLException * if the descriptor is invalid or missing */ public static CollectionReaderDescription getDescription() throws InvalidXMLException { InputStream descStream = FileSystemCollectionReader.class .getResourceAsStream("FileSystemCollectionReader.xml"); return UIMAFramework.getXMLParser().parseCollectionReaderDescription( new XMLInputSource(descStream, null)); }
/** * Returns an analysis engine for the given annotator. * * @param annotator is the name of the annotator (with or without .xml * extension). * @return the AnalysisEngine */ public static AnalysisEngine getAnalysisEngine(String annotator) { // Try to find the URL pointing at the annotator resource URL resource = Typesystem.class.getResource(getAnnotator(annotator)); if (resource == null) { throw new TypesystemException("Annotator " + annotator + " not found", null); } // Create the AnalysisEngine try { final XMLInputSource xml = new XMLInputSource(resource); final AnalysisEngineDescription aeDescription = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(xml); return UIMAFramework.produceAnalysisEngine(aeDescription); } catch (UIMAException | IOException ex) { throw new TypesystemException("getAnalysisEngine failed", ex); } }
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; }
AnalysisEngineDescription taeDescription = UIMAFramework.getXMLParser().parseAnalysisEngineDescription( new XMLInputSource(new File(taeDescriptionLocation))); AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(taeDescription); System.out.println("analysis engine created."); CasConsumerDescription casConsumerDescription = UIMAFramework.getXMLParser().parseCasConsumerDescription( new XMLInputSource(new File(casConsumerDescriptorLocation))); CasConsumer casConsumer = UIMAFramework.produceCasConsumer(casConsumerDescription); System.out.println("CasConsumer initialized. Calling processCas....");
public static CollectionReader getCR(File collectionReaderDescriptorFile) throws ResourceInitializationException { try { XMLInputSource xmlInputSource = new XMLInputSource(collectionReaderDescriptorFile); XMLParser xmlParser = UIMAFramework.getXMLParser(); ResourceSpecifier resourceSpecifier = xmlParser.parseResourceSpecifier(xmlInputSource); CollectionReader collectionReader = UIMAFramework.produceCollectionReader(resourceSpecifier); return collectionReader; } catch (IOException ioe) { throw new ResourceInitializationException(ioe); } catch (InvalidXMLException ixe) { throw new ResourceInitializationException(ixe); } }
public void openCpeDescriptor(File aFile) throws InvalidXMLException, IOException, CpeDescriptorException, ResourceConfigurationException { currentCpeDesc = UIMAFramework.getXMLParser().parseCpeDescription(new XMLInputSource(aFile)); try { URL specifierUrl = casProcs[i].getCpeComponentDescriptor().findAbsoluteUrl(defaultResourceManager); ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier( new XMLInputSource(specifierUrl)); if (isCasConsumerSpecifier(specifier)) { success = addConsumer(casProcs[i]);
public void initTypeDescriptor(String cpeDescriptor) { ArrayList<TypeSystemDescription> typeSystems = new ArrayList<>(); try { currentCpeDesc = UIMAFramework.getXMLParser().parseCpeDescription(new XMLInputSource(cpeDescriptor)); removeFailedDescriptors(new File(cpeDescriptor)); File rootFolder = new File(currentCpeDesc.getSourceUrl().getFile()).getParentFile(); for (CpeCollectionReader collReader : collRdrs) { File descFile = new File(rootFolder + System.getProperty("file.separator") + collReader.getDescriptor().getImport().getLocation()); CollectionReaderDescription crd = UIMAFramework.getXMLParser().parseCollectionReaderDescription(new XMLInputSource(descFile)); TypeSystemDescription typeSystem = crd.getCollectionReaderMetaData().getTypeSystem(); typeSystem.resolveImports(); AnalysisEngineDescription aed = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(new XMLInputSource(descFile)); TypeSystemDescription typeSystem = aed.getAnalysisEngineMetaData().getTypeSystem(); typeSystem.resolveImports();
XMLParser xmlParser = UIMAFramework.getXMLParser(); xmlSource = (xmlDescFile != null) ? new XMLInputSource(xmlDescFile) : new XMLInputSource( xmlDescUrl); resourceSpec = xmlParser.parseResourceSpecifier(xmlSource); } catch (UIMAException err) { __errTableByUri.put( xmlDescUri, err ); try { xmlParser.parseCpeDescription(xmlSource); uimaCompCtg = CPE_CONFIGURATION_CTG; __errTableByUri.remove( xmlDescUri ); try { xmlParser.parseTypeSystemDescription(xmlSource); uimaCompCtg = TYPE_SYSTEM_CTG; __errTableByUri.remove( xmlDescUri ); try { xmlParser.parseResourceManagerConfiguration(xmlSource); uimaCompCtg = REUSABLE_RESOURCE_CTG; __errTableByUri.remove( xmlDescUri );
public synchronized void resolveImports(ResourceManager aResourceManager) throws InvalidXMLException { Import theImport = getImport(); if (theImport != null) { URL url = theImport.findAbsoluteUrl(aResourceManager); InputStream stream = null; try { stream = url.openStream(); XMLInputSource input = new XMLInputSource(url); ResourceSpecifier spec = UIMAFramework.getXMLParser().parseResourceSpecifier(input); setSpecifier(spec); setImport(null); } catch (IOException e) { throw new InvalidXMLException(e); } finally { try { if (stream != null) { stream.close(); } } catch (IOException e1) { UIMAFramework.getLogger(this.getClass()).log(Level.SEVERE, "", e1); } } } }
public static CpeDescription loadCpeDescription(Path path) throws BiomedicusException { CpeDescription cpeDescription; try { XMLInputSource inputSource = new XMLInputSource(path.toFile()); cpeDescription = UIMAFramework.getXMLParser().parseCpeDescription(inputSource); } catch (InvalidXMLException | IOException e) { throw new BiomedicusException(e); } return cpeDescription; } }
XMLInputSource in1 = new XMLInputSource(descriptorUrl); ResourceSpecifier colReaderSp = UIMAFramework.getXMLParser() .parseCollectionReaderDescription(in1); Map additionalParams = new HashMap(); additionalParams.put(Resource.PARAM_UIMA_CONTEXT, collectionReaderContext); colreader = (BaseCollectionReader) UIMAFramework.produceResource(BaseCollectionReader.class, colReaderSp, getResourceManager(), additionalParams); XMLInputSource in4 = new XMLInputSource(casInitDescUrl); ResourceSpecifier casIniSp = UIMAFramework.getXMLParser().parseCasInitializerDescription( in4);
/** * Creates a resource specifier from a given file * * @param aFileResource resource filename * @return ResourceSpecifier - new instance * * @throws InvalidXMLException invalid xml * @throws ResourceInitializationException init failed * @throws IOException io failed */ public static ResourceSpecifier produceResourceSpecifier(String aFileResource) throws InvalidXMLException, ResourceInitializationException, IOException { XMLInputSource input = resolveImportByName(aFileResource, UIMAFramework .newDefaultResourceManager()); return UIMAFramework.getXMLParser().parseResourceSpecifier(input); }