/** * @return import instance. This is preferred way to include the AE into * pipeline, especially when a pipeline descriptor is expected to be * serialized into XML. * @see PipelineDescriptorUtils#createAggregateDescription(java.util.List, * java.util.List) */ public static Import getAEImport() { Import result = new Import_impl(); result.setName(AE_SENTENCE_SPLITTER); return result; }
/** * @return import instance. This is preferred way to include the AE into * pipeline, especially when a pipeline descriptor is expected to be * serialized into XML. * @see PipelineDescriptorUtils#createAggregateDescription(java.util.List, * java.util.List) */ public static Import getAEImport() { Import result = new Import_impl(); result.setName(AE_TOKENIZER); return result; }
/** * Creates a {@link FsIndexCollection} from descriptor names. * * @param descriptorNames * The fully qualified, Java-style, dotted descriptor names. * @return a {@link FsIndexCollection} that includes the indexes from all of the specified files. */ public static FsIndexCollection createFsIndexCollection(String... descriptorNames) { List<Import> imports = new ArrayList<Import>(); for (String descriptorName : descriptorNames) { Import imp = new Import_impl(); imp.setName(descriptorName); imports.add(imp); } Import[] importArray = new Import[imports.size()]; FsIndexCollection fsIndexCollection = new FsIndexCollection_impl(); fsIndexCollection.setImports(imports.toArray(importArray)); return fsIndexCollection; }
/** * Creates a TypeSystemDescription from descriptor names. * * @param descriptorNames * The fully qualified, Java-style, dotted descriptor names. * @return A TypeSystemDescription that includes the types from all of the specified files. */ public static TypeSystemDescription createTypeSystemDescription(String... descriptorNames) { TypeSystemDescription typeSystem = new TypeSystemDescription_impl(); List<Import> imports = new ArrayList<Import>(); for (String descriptorName : descriptorNames) { Import imp = new Import_impl(); imp.setName(descriptorName); imports.add(imp); } Import[] importArray = new Import[imports.size()]; typeSystem.setImports(imports.toArray(importArray)); return typeSystem; }
imp.setName(fileName.substring(partStart)); try { imp.findAbsoluteUrl(rm);
private static XMLInputSource resolveImportByName(String aFileResource, ResourceManager aResourceManager) throws InvalidXMLException, ResourceInitializationException, IOException { XMLInputSource input; if (aFileResource.startsWith(IMPORT_BY_NAME_PREFIX)) { Import theImport = new Import_impl(); theImport.setName(aFileResource.substring(IMPORT_BY_NAME_PREFIX.length())); input = new XMLInputSource(theImport.findAbsoluteUrl(aResourceManager)); } else { input = new XMLInputSource(aFileResource); } return input; }
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); } }
public static String resolveByName(String input) { ResourceManager resourceManager = UIMAFramework.newDefaultResourceManager(); Import theImport = new Import_impl(); theImport.setName(input); try { return theImport.findAbsoluteUrl(resourceManager).toExternalForm(); } catch (InvalidXMLException e) { if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.SEVERE)) { UIMAFramework.getLogger(CLASS_NAME).logrb(Level.SEVERE, XsltImportByName.class.getName(), "resolveByName", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_exception__SEVERE", e.toString()); } return null; } }
/** * Get a CollectionReader from the name (Java-style, dotted) of an XML descriptor file, and a set * of configuration parameters. * * @param descriptorName * The fully qualified, Java-style, dotted name of the XML descriptor file. * @param configurationData * Any additional configuration parameters to be set. These should be supplied as (name, * value) pairs, so there should always be an even number of parameters. * @return The AnalysisEngine created from the XML descriptor and the configuration parameters. * @throws UIMAException * if the descriptor could not be created or if the component could not be instantiated * @throws IOException * if the descriptor could not be read */ public static CollectionReader createReader(String descriptorName, Object... configurationData) throws UIMAException, IOException { Import imp = UIMAFramework.getResourceSpecifierFactory().createImport(); imp.setName(descriptorName); URL url = imp.findAbsoluteUrl(ResourceManagerFactory.newResourceManager()); ResourceSpecifier specifier = createResourceCreationSpecifier(url, configurationData); return UIMAFramework.produceCollectionReader(specifier, ResourceManagerFactory.newResourceManager(), null); }