Refine search
public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); this.context = context; Logger mLogger = context.getLogger(); if (mLogger.isLoggable(Level.INFO)) { mLogger.log(Level.INFO, "Initializing the OpenNLP Categorizer."); } DoccatModel model; try { DoccatModelResource modelResource = (DoccatModelResource) context .getResourceObject(UimaUtil.MODEL_PARAMETER); model = modelResource.getModel(); } catch (ResourceAccessException e) { throw new ResourceInitializationException(e); } mCategorizer = new DocumentCategorizerME(model); }
private Map<String, List<String>> readLabelsAndFeaturesFromFile(File file) throws ResourceInitializationException { Map<String, List<String>> map = new HashMap<>(); try (BufferedReader reader = new BufferedReader(new FileReader(file))) { String line = reader.readLine(); while (line != null) { line = line.trim(); String[] split = line.split("\\s+"); String label = split[0]; List<String> features = new ArrayList<>(); for (int i = 1; i < split.length; i++) { features.add(split[i]); } map.put(label, features); line = reader.readLine(); } } catch (IOException e) { throw new ResourceInitializationException(e); } return map; }
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); if (embedding == null) { throw new ResourceInitializationException("The provided embedding file is null", null); } String line = null; try { BufferedReader reader = new BufferedReader( new InputStreamReader(new FileInputStream(new File(embedding)), "utf-8")); while ((line = reader.readLine()) != null) { String[] split = line.split(" "); vocab.add(split[0]); } reader.close(); } catch (IOException e) { throw new ResourceInitializationException(e); } }
@Override protected void doInitialize(UimaContext context) throws ResourceInitializationException { if (file == null || !file.canRead() || !file.isFile()) { throw new ResourceInitializationException( new InvalidParameterException("Specified parameter '" + PARAM_FILE + "' was not valid")); } try { br = new BufferedReader( new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8)); } catch (IOException ioe) { throw new ResourceInitializationException(ioe); } }
@Override public void initialize() throws ResourceInitializationException { this.dataset = (String) getConfigParameterValue("dataset"); File file = new File( ((String) getConfigParameterValue(PARAM_QUESTIONFILE)).trim()); getLogger().log(Level.INFO,"Loading questions from " + file.getAbsolutePath()); // if input file does not exist, throw exception if (!file.exists()) { getLogger().log(Level.SEVERE,"The question file does not exist."); throw new ResourceInitializationException( ResourceConfigurationException.DIRECTORY_NOT_FOUND, new Object[] { PARAM_QUESTIONFILE, this.getMetaData().getName(), file.getPath() }); } try { this.reader = new BufferedReader( new InputStreamReader(new FileInputStream(file), "UTF8")); } catch (Exception e) { throw new ResourceInitializationException(e); } }
if (anObject instanceof UimaTimer) { timer = (UimaTimer) anObject; if (UIMAFramework.getLogger().isLoggable(Level.CONFIG)) { UIMAFramework.getLogger(TimerFactory.class).logrb(Level.CONFIG, TimerFactory.class.getName(), "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_show_timer_class__CONFIG", throw new ResourceInitializationException(ResourceInitializationException.CLASS_NOT_FOUND, new Object[] { aClassName, "CPE" }, e); } catch (IllegalAccessException e) { throw new ResourceInitializationException( ResourceInitializationException.COULD_NOT_INSTANTIATE, new Object[] { aClassName, "CPE" }, e); } catch (InstantiationException e) { throw new ResourceInitializationException( ResourceInitializationException.COULD_NOT_INSTANTIATE, new Object[] { aClassName, "CPE" }, e); if (UIMAFramework.getLogger().isLoggable(Level.CONFIG)) { UIMAFramework.getLogger(TimerFactory.class).logrb(Level.CONFIG, TimerFactory.class.getName(), "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
private static void checkForNull(Object value, String parameterName) throws ResourceInitializationException { if (value == null) { throw new ResourceInitializationException( ExceptionMessages.MESSAGE_CATALOG, ExceptionMessages.PARAMETER_NOT_FOUND, new Object[] {parameterName}); } }
/** * Initializes the current instance with the given context. * <p> * Note: Do all initialization in this method, do not use the constructor. */ public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); SentenceModel model; try { SentenceModelResource modelResource = (SentenceModelResource) context .getResourceObject(UimaUtil.MODEL_PARAMETER); model = modelResource.getModel(); } catch (ResourceAccessException e) { throw new ResourceInitializationException(e); } sentenceDetector = new SentenceDetectorME(model); }
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); featureStore = new SimpleFeatureStore(); if (featureExtractors.length == 0) { context.getLogger().log(Level.SEVERE, "No feature extractors have been defined."); throw new ResourceInitializationException(); } }
this.uimaLogger = UIMAFramework.getLogger(this.getClass()); this.aeDesc = aeDescriptorFileName; this.numInstances = numInstances; this.uimaLogger.log(Level.INFO, "Starting C++ service: " + commandArgs.toString()); this.uimaLogger.log(Level.INFO, " env params: " + envVarMap.toString()); startService(); throw new ResourceInitializationException(new IOException("JmxManagement object is null.")); throw new ResourceInitializationException(e); } catch (UIMAException e) { throw new ResourceInitializationException(e); } catch (MalformedObjectNameException e) { throw new ResourceInitializationException(e); } catch (NullPointerException e) { throw new ResourceInitializationException(e); } catch (Exception e) { throw new ResourceInitializationException(e);
public static AnalysisEngine getAE(File analysisEngineDescriptorFile) throws ResourceInitializationException { try { XMLInputSource xmlInputSource = new XMLInputSource(analysisEngineDescriptorFile); XMLParser xmlParser = UIMAFramework.getXMLParser(); ResourceSpecifier resourceSpecifier = xmlParser.parseResourceSpecifier(xmlInputSource); AnalysisEngine analysisEngine = UIMAFramework.produceAnalysisEngine(resourceSpecifier); return analysisEngine; } catch (IOException ioe) { throw new ResourceInitializationException(ioe); } catch (InvalidXMLException ixe) { throw new ResourceInitializationException(ixe); } }
/** * Creates a {@link FsIndexCollection} from all index descriptions that can be found via the * pattern specified in the system property {@code org.apache.uima.fit.fsindex.import_pattern} or * via the {@code META-INF/org.apache.uima.fit/fsindexes.txt} files in the classpath. * * @return the auto-scanned indexes. * @throws ResourceInitializationException * if the index collection could not be assembled */ public static FsIndexCollection createFsIndexCollection() throws ResourceInitializationException { List<FsIndexDescription> fsIndexList = new ArrayList<FsIndexDescription>(); for (String location : scanIndexDescriptors()) { try { XMLInputSource xmlInput = new XMLInputSource(location); FsIndexCollection fsIdxCol = getXMLParser().parseFsIndexCollection(xmlInput); fsIdxCol.resolveImports(); fsIndexList.addAll(asList(fsIdxCol.getFsIndexes())); LogFactory.getLog(FsIndexFactory.class).debug("Detected index at [" + location + "]"); } catch (IOException e) { throw new ResourceInitializationException(e); } catch (InvalidXMLException e) { LogFactory.getLog(FsIndexFactory.class).warn( "[" + location + "] is not a index descriptor file. Ignoring.", e); } } return createFsIndexCollection(fsIndexList.toArray(new FsIndexDescription[fsIndexList.size()])); }
throw new ResourceInitializationException(e1); UIMAFramework.getLogger().logrb(Level.CONFIG, ResourceManager_impl.class.getName(), "initializeExternalResources", LOG_RESOURCE_BUNDLE, "UIMA_overridden_resource__CONFIG", new Object[] { e.getKey(), aQualifiedContextName, definingContext }); } else { UIMAFramework.getLogger().logrb(Level.WARNING, ResourceManager_impl.class.getName(), "initializeExternalResources", LOG_RESOURCE_BUNDLE, "UIMA_duplicate_resource_name__WARNING", throw new ResourceInitializationException(e1);
public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); try { this.chineseWordSegments = (ChineseSegment) context.getResourceObject(CHINESE_WORD_SEGMENTS); this.chineseForeignNameSegments = (ChineseSegment) context.getResourceObject(CHINESE_FOREIGN_NAME_SEGMENTS); this.chineseNumberSegments = (ChineseSegment) context.getResourceObject(CHINESE_NUMBER_SEGMENTS); this.annotationType = (String) context.getConfigParameterValue(ANNOTATION_TYPE); } catch (ResourceAccessException e) { throw new ResourceInitializationException(e); } }
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 static InputStream getOptionalResourceAsStream(UimaContext context, String name) throws ResourceInitializationException { InputStream inResource; try { inResource = context.getResourceAsStream(name); } catch (ResourceAccessException e) { throw new ResourceInitializationException(e); } return inResource; }
String systemPropValue = (String) systemProps.get(key); if (!systemPropValue.equals(value)) { UIMAFramework.getLogger(this.getClass()).logrb( Level.WARNING, this.getClass().getName(), UIMAFramework.getLogger(this.getClass()).logrb(Level.CONFIG, this.getClass().getName(), "initialize", LOG_RESOURCE_BUNDLE, "UIMA_pear_runtime_set_system_var__CONFIG", new Object[] { key + "=" + value, pkgBrowser.getRootDirectory().getName() }); innerRM = createRM(sp, pkgBrowser, applicationRM); c1.put(sp, innerRM); UIMAFramework.getLogger(this.getClass()).logrb(Level.CONFIG, this.getClass().getName(), "initialize", LOG_RESOURCE_BUNDLE, "UIMA_pear_runtime_add_RM_map", new Object[] { sp.classPath, sp.dataPath }); this.ae = UIMAFramework.produceAnalysisEngine(specifier, innerRM, clonedAdditionalParameters); } catch (IOException ex) { throw new ResourceInitializationException(ex); } catch (InvalidXMLException ex) { throw new ResourceInitializationException(ex);
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); try { featureExtractors = new FeatureResourceLoader(tcModelLocation) .loadExternalResourceDescriptionOfFeatures(); mlAdapter = initMachineLearningAdapter(tcModelLocation); featureMode = initFeatureMode(tcModelLocation); learningMode = initLearningMode(tcModelLocation); validateUimaParameter(); AnalysisEngineDescription connector = getSaveModelConnector( tcModelLocation.getAbsolutePath(), mlAdapter, learningMode, featureMode, featureExtractors); engine = UIMAFramework.produceAnalysisEngine(connector, getModelFeatureAwareResourceManager(tcModelLocation), null); } catch (Exception e) { throw new ResourceInitializationException(e); } }
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.CONFIG, CLASS_NAME.getName(), "produceResource", LOG_RESOURCE_BUNDLE, "UIMA_trying_resource_class__CONFIG", currentClass.getName()); currentException = new ResourceInitializationException( ResourceInitializationException.COULD_NOT_INSTANTIATE, new Object[] { currentClass.getName(), aSpecifier.getSourceUrlString() }, e); } catch (InstantiationException e) { currentException = new ResourceInitializationException( ResourceInitializationException.COULD_NOT_INSTANTIATE, new Object[] { currentClass.getName(), aSpecifier.getSourceUrlString() }, e); } catch (Throwable t) { currentException = new ResourceInitializationException( ResourceInitializationException.ERROR_INITIALIZING_FROM_DESCRIPTOR, new Object[] { currentClass.getName(), aSpecifier.getSourceUrlString() }, t); } finally { if (currentException != null) { currentException.fillInStackTrace();
public void initialize(UimaContext aContext) throws ResourceInitializationException { super.initialize(aContext); logger.info(Arrays.asList(aContext.getConfigParameterNames())); context = aContext; try { configInit(); } catch (Exception ace) { throw new ResourceInitializationException(ace); } }