/** * 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; }
/** * 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; }
/** * Parses and returns the descriptor for this Analysis Gnein. The descriptor is stored in the * uima-core.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 AnalysisEngineDescription getDescription() throws InvalidXMLException { InputStream descStream = XmlDetagger.class .getResourceAsStream("XmlDetagger.xml"); return UIMAFramework.getXMLParser().parseAnalysisEngineDescription( new XMLInputSource(descStream, null)); }
private void addProcessingResourceMetadata(String mapkey, String aDescriptorName) throws Exception { AnalysisEngineDescription specifier = UIMAFramework.getXMLParser() .parseAnalysisEngineDescription(new XMLInputSource(new File(aDescriptorName))); AnalysisEngineMetaData meta = specifier.getAnalysisEngineMetaData(); addMetadata(meta); processingResourceMap.put(mapkey, meta); }
public void setMetadata(String aDescriptorName) throws Exception { AnalysisEngineDescription specifier = UIMAFramework.getXMLParser() .parseAnalysisEngineDescription(new XMLInputSource(new File(aDescriptorName))); AnalysisEngineMetaData meta = specifier.getAnalysisEngineMetaData(); addMetadata(meta); }
private static CAS getTypeSystemFromDescriptor(String descriptor) throws InvalidXMLException, IOException, ResourceInitializationException, CASException { XMLParser xmlParser = UIMAFramework.getXMLParser(); AnalysisEngineDescription tsDesc = xmlParser.parseAnalysisEngineDescription(new XMLInputSource(descriptor)); return CasCreationUtils.createCas(tsDesc); }
protected AnalysisEngineDescription promptForAE() throws IOException, InvalidXMLException, ResourceInitializationException { if (med1.getTAEfile() != null) { File taeFile = new File(med1.getTAEfile()); XMLInputSource in = new XMLInputSource(taeFile); AnalysisEngineDescription aed = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in); return aed; } else { String taeDir = med1.getTAEfile(); JFileChooser chooser = new JFileChooser(taeDir); chooser.setDialogTitle("Select the Analysis Engine that Generated this Output"); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); int returnVal = chooser.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { XMLInputSource in = new XMLInputSource(chooser.getSelectedFile()); return UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in); } else { return null; } } }
protected AnalysisEngineDescription promptForAE() throws IOException, InvalidXMLException, ResourceInitializationException { if (med1.getTAEfile() != null) { File taeFile = new File(med1.getTAEfile()); XMLInputSource in = new XMLInputSource(taeFile); AnalysisEngineDescription aed = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in); return aed; } else { String taeDir = med1.getTAEfile(); JFileChooser chooser = new JFileChooser(taeDir); chooser.setDialogTitle("Select the Analysis Engine that Generated this Output"); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); int returnVal = chooser.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { XMLInputSource in = new XMLInputSource(chooser.getSelectedFile()); return UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in); } else { return null; } } }
private static CAS getTypeSystemFromDescriptor(String descriptor) throws InvalidXMLException, IOException, ResourceInitializationException, CASException { XMLParser xmlParser = UIMAFramework.getXMLParser(); AnalysisEngineDescription tsDesc = xmlParser.parseAnalysisEngineDescription(new XMLInputSource(descriptor)); return CasCreationUtils.createCas(tsDesc); }
private static CAS getTypeSystemFromDescriptor(String descriptor) throws InvalidXMLException, IOException, ResourceInitializationException, CASException { XMLParser xmlParser = UIMAFramework.getXMLParser(); AnalysisEngineDescription tsDesc = xmlParser.parseAnalysisEngineDescription(new XMLInputSource(descriptor)); return CasCreationUtils.createCas(tsDesc); }
File taeFile = new File(med1.getTAEfile()); XMLInputSource in = new XMLInputSource(taeFile); AnalysisEngineDescription aed = UIMAFramework.getXMLParser().parseAnalysisEngineDescription( in); return aed; if (returnVal == JFileChooser.APPROVE_OPTION) { XMLInputSource in = new XMLInputSource(chooser.getSelectedFile()); return UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in); } else { return null;
private static CAS getTypeSystemFromDescriptor(String descriptor) throws InvalidXMLException, IOException, ResourceInitializationException, CASException { XMLParser xmlParser = UIMAFramework.getXMLParser(); AnalysisEngineDescription tsDesc = xmlParser.parseAnalysisEngineDescription(new XMLInputSource(descriptor)); return CasCreationUtils.createCas(tsDesc); }
/** * If the current AE filename is not know ask for it. Then parse the selected file and return the * AnalysisEngineDescription object. * * @return the selected AnalysisEngineDescription, null if the user cancelled */ protected AnalysisEngineDescription promptForAE() throws IOException, InvalidXMLException, ResourceInitializationException { if (med1.getTAEfile() != null) { File taeFile = new File(med1.getTAEfile()); XMLInputSource in = new XMLInputSource(taeFile); AnalysisEngineDescription aed = UIMAFramework.getXMLParser().parseAnalysisEngineDescription( in); return aed; } else { String taeDir = med1.getTAEfile(); JFileChooser chooser = new JFileChooser(taeDir); chooser.setDialogTitle("Select the Analysis Engine that Generated this Output"); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); int returnVal = chooser.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { XMLInputSource in = new XMLInputSource(chooser.getSelectedFile()); return UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in); } else { return null; } } }
/** * If the current AE filename is not know ask for it. Then parse the selected file and return the * AnalysisEngineDescription object. * * @return the selected AnalysisEngineDescription, null if the user cancelled */ protected AnalysisEngineDescription promptForAE() throws IOException, InvalidXMLException, ResourceInitializationException { if (med1.getTAEfile() != null) { File taeFile = new File(med1.getTAEfile()); XMLInputSource in = new XMLInputSource(taeFile); AnalysisEngineDescription aed = UIMAFramework.getXMLParser().parseAnalysisEngineDescription( in); return aed; } else { String taeDir = med1.getTAEfile(); JFileChooser chooser = new JFileChooser(taeDir); chooser.setDialogTitle("Select the Analysis Engine that Generated this Output"); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); int returnVal = chooser.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { XMLInputSource in = new XMLInputSource(chooser.getSelectedFile()); return UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in); } else { return null; } } }
public static void main(String[] args) throws Exception { String dictionaryResourceName = DICTIONARY_RESOURCE_NAME; if (args.length == 2) { // do nothing } else if (args.length == 3) { dictionaryResourceName = args[2]; } else { usage(); System.exit(17); } AnalysisEngineDescription conceptMapperDesc = UIMAFramework.getXMLParser() .parseAnalysisEngineDescription(new XMLInputSource(args[0])); AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(conceptMapperDesc); DictionaryResource_impl dict = (DictionaryResource_impl) ae.getResourceManager().getResource( dictionaryResourceName); OutputStream output = new BufferedOutputStream(new FileOutputStream(args[1])); dict.serializeEntries(output); output.close(); ae.destroy(); // for some reason JVM won't exit normally, // probably because CPM threads are alive? System.exit(0); }
private static void setImportsByLocation(File dir, String descName) { FileOutputStream fos = null; try { File file = new File(dir, descName); AnalysisEngineDescription description = UIMAFramework.getXMLParser() .parseAnalysisEngineDescription(new XMLInputSource(file)); Import[] imports = description.getAnalysisEngineMetaData().getTypeSystem().getImports(); for (Import each : imports) { String name = each.getName(); String[] split = name.split("[.]"); String location = split[split.length - 1] + ".xml"; each.setName(null); each.setLocation(location); } fos = new FileOutputStream(file); description.toXML(fos); } catch (InvalidXMLException | IOException | SAXException e) { RutaIdeUIPlugin.error(e); } finally { IOUtils.closeQuietly(fos); } }
/** * 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); } }
for (CpeCasProcessor casProcessor : cpeCasProcessors) { File descFile = new File(rootFolder + System.getProperty("file.separator") + casProcessor.getCpeComponentDescriptor().getImport().getLocation()); AnalysisEngineDescription aed = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(new XMLInputSource(descFile)); TypeSystemDescription typeSystem = aed.getAnalysisEngineMetaData().getTypeSystem(); typeSystem.resolveImports();
XMLParser parser = UIMAFramework.getXMLParser(); XMLInputSource source = new XMLInputSource(preprocessDescFile); builder.add(parser.parseAnalysisEngineDescription(source));
XMLParser parser = UIMAFramework.getXMLParser(); XMLInputSource source = new XMLInputSource(preprocessDescFile); builder.add(parser.parseAnalysisEngineDescription(source));