org.apache.uima.resource.ResourceInitializationException Java Examples
The following examples show how to use
org.apache.uima.resource.ResourceInitializationException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ParseHeadProximityAnswerScorer.java From bioasq with Apache License 2.0 | 6 votes |
@Override public boolean initialize(ResourceSpecifier aSpecifier, Map<String, Object> aAdditionalParams) throws ResourceInitializationException { boolean ret = super.initialize(aSpecifier, aAdditionalParams); String stoplistFile = (String) getParameterValue("stoplist"); try { stoplist = Resources.readLines(getClass().getResource(stoplistFile), Charsets.UTF_8).stream() .collect(toSet()); } catch (IOException e) { throw new ResourceInitializationException(e); } windowSize = (int) getParameterValue("window-size"); infinity = (double) getParameterValue("infinity"); smoothing = (double) getParameterValue("smoothing"); return ret; }
Example #2
Source File: DeduplicatorAnnotator.java From bluima with Apache License 2.0 | 6 votes |
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); annotationClassesList = Arrays.asList(annotationClasses); // validate that the class exists for (String annotationClass : annotationClasses) { try { @SuppressWarnings({ "unchecked", "unused" }) Class<? extends Annotation> classz = (Class<? extends Annotation>) Class .forName(annotationClass); } catch (Exception e) { throw new ResourceInitializationException(e); } } }
Example #3
Source File: ClassifierTrainer.java From bioasq with Apache License 2.0 | 6 votes |
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); String candidateProviderName = UimaContextHelper .getConfigParameterStringValue(context, "candidate-provider"); candidateProvider = ProviderCache.getProvider(candidateProviderName, CandidateProvider.class); String scorerNames = UimaContextHelper.getConfigParameterStringValue(context, "scorers"); scorers = ProviderCache.getProviders(scorerNames, Scorer.class).stream() .map(scorer -> (Scorer<? super T>) scorer).collect(toList()); String classifierName = UimaContextHelper.getConfigParameterStringValue(context, "classifier"); classifier = ProviderCache.getProvider(classifierName, ClassifierProvider.class); cvPredictFile = UimaContextHelper .getConfigParameterStringValue(context, "cv-predict-file", null); if (cvPredictFile != null) { iduris = new ArrayList<>(); } X = new ArrayList<>(); Y = new ArrayList<>(); atLeastOneCorrect = UimaContextHelper .getConfigParameterBooleanValue(context, "at-least-one-correct", true); resampleType = ClassifierProvider.ResampleType.valueOf( UimaContextHelper.getConfigParameterStringValue(context, "resample-type", "NONE")); }
Example #4
Source File: CasStatCounter.java From termsuite-core with Apache License 2.0 | 6 votes |
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); this.sw = Stopwatch.createStarted(); if(traceFileName != null) { File file = new File(traceFileName); try { this.fileWriter = new FileWriter(file); } catch (IOException e) { LOGGER.error("Could not create a writer to file {}", traceFileName); throw new ResourceInitializationException(e); } this.periodicStatEnabled = docPeriod > 0; LOGGER.info("Tracing time performance to file {}", file.getAbsolutePath()); } }
Example #5
Source File: WhiteTextCollectionReader.java From bluima with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Override public void initialize(UimaContext context) throws ResourceInitializationException { try { if (corpus == null) { corpus = CorporaHelper.CORPORA_HOME + "/src/main/resources/pear_resources/whitetext/WhiteText.1.3.xml"; } checkArgument(new File(corpus).exists()); InputStream corpusIs = new FileInputStream(corpus); SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(corpusIs); Element rootNode = doc.getRootElement(); articleIt = rootNode.getChildren("PubmedArticle").iterator(); } catch (Exception e) { throw new ResourceInitializationException( ResourceConfigurationException.NONEXISTENT_PARAMETER, new Object[] { corpus }); } }
Example #6
Source File: MongoGazetteerTest.java From baleen with Apache License 2.0 | 6 votes |
@BeforeClass public static void beforeClass() throws ResourceInitializationException { sfr = new SharedFongoResource(); MongoDatabase db = sfr.getDB(); MongoCollection<Document> coll = db.getCollection("gazetteer"); coll.insertMany( Arrays.asList( new Document(VALUE, EN_HELLO2), new Document(VALUE, Arrays.asList("hi", EN_HELLO, "heya")), new Document(VALUE, Arrays.asList("konnichiwa", JP_HELLO)).append(LANGUAGE, "jp"), new Document(VALUE, Arrays.asList(DE_HELLO)) .append(LANGUAGE, "de") .append(TRANSLATION, "good day"), new Document(VALUE, Arrays.asList("hej")).append(LANGUAGE, "se"))); }
Example #7
Source File: TemplateAnnotatorTest.java From baleen with Apache License 2.0 | 6 votes |
@Test public void testCreateFieldAnnotationsFromSelectorFileWithRegexDefaultUsed() throws AnalysisEngineProcessException, ResourceInitializationException, IOException { Path definitionFile = createGoodRecordDefinitionWithRegexDefaultNeeded(); try { processJCas(TemplateAnnotator.PARAM_RECORD_DEFINITIONS_DIRECTORY, tempDirectory.toString()); assertRecordCoversParas2to4(); TemplateField field1 = JCasUtil.selectSingle(jCas, TemplateField.class); assertEquals(159, field1.getBegin()); assertEquals(159, field1.getEnd()); assertEquals("", field1.getCoveredText()); assertEquals("horse", field1.getValue()); assertEquals(2, JCasUtil.select(jCas, Metadata.class).size()); } finally { Files.delete(definitionFile); } }
Example #8
Source File: EntityGraphFileTest.java From baleen with Apache License 2.0 | 6 votes |
@Test public void testGraphML() throws AnalysisEngineProcessException, ResourceInitializationException, IOException, URISyntaxException { processJCas( EntityGraph.PARAM_OUTPUT_DIRECTORY, tempDirectory.toString(), EntityGraph.PARAM_GRAPH_FORMAT, GraphFormat.GRAPHML.toString()); Path actual = tempDirectory.resolve(tempDirectory.toFile().list()[0]); Path expected = createAndFailIfMissing(actual, EXPECTED_GRAPHML_FILE, GRAPHML_NAME); assertPathsEqual(expected, actual); Files.delete(actual); }
Example #9
Source File: BaleenContentExtractor.java From baleen with Apache License 2.0 | 6 votes |
@Override public final boolean initialize(ResourceSpecifier specifier, Map<String, Object> additionalParams) throws ResourceInitializationException { boolean result = super.initialize(specifier, additionalParams); UimaContext context = getUimaContext(); String pipelineName = UimaUtils.getPipelineName(context); monitor = createMonitor(pipelineName); support = createSupport(pipelineName, context); monitor.startFunction("initialize"); doInitialize(context, additionalParams); monitor.finishFunction("initialize"); return result; }
Example #10
Source File: SharedCountryResource.java From baleen with Apache License 2.0 | 6 votes |
@Override protected boolean doInitialize(ResourceSpecifier specifier, Map<String, Object> additionalParams) throws ResourceInitializationException { ObjectMapper mapper = new ObjectMapper(); synchronized (this) { UimaMonitor monitor = getMonitor(); if (demonyms == null) { monitor.info("Shared country resource initialising"); JsonNode countriesJson = loadCountriesJson(mapper, monitor); countryNames = ImmutableMap.copyOf(loadCountryNames(countriesJson, monitor)); demonyms = ImmutableMap.copyOf(loadDemonyms(countriesJson, monitor)); geoJson = ImmutableMap.copyOf(loadCountriesGeoJson(mapper, monitor)); } else { monitor.info("Shared country resource already initialised"); } } return true; }
Example #11
Source File: MentionedAgainTest.java From baleen with Apache License 2.0 | 6 votes |
@Test public void testMultiple() throws AnalysisEngineProcessException, ResourceInitializationException { jCas.setDocumentText("John went to London. I saw John there. He's a great guy John."); Person p1 = new Person(jCas); p1.setBegin(0); p1.setEnd(4); p1.setValue("John"); p1.addToIndexes(); Person p2 = new Person(jCas); p2.setBegin(27); p2.setEnd(31); p2.setValue("John"); p2.addToIndexes(); processJCas(); List<Entity> select = new ArrayList<>(JCasUtil.select(jCas, Person.class)); assertEquals(3, select.size()); assertEquals("John", select.get(0).getValue()); assertEquals("John", select.get(1).getValue()); assertEquals("John", select.get(2).getValue()); }
Example #12
Source File: RelationTypeFilter.java From baleen with Apache License 2.0 | 6 votes |
@Override public void doInitialize(final UimaContext aContext) throws ResourceInitializationException { super.doInitialize(aContext); final MongoCollection<Document> dbCollection = mongo.getDB().getCollection(collection); for (Document o : dbCollection.find()) { RelationConstraint constraint = new RelationConstraint( (String) o.get(typeField), (String) o.get(subTypeField), (String) o.get(posField), (String) o.get(sourceField), (String) o.get(targetField)); if (constraint.isValid()) { Set<RelationConstraint> set = constraints.get(constraint.getType()); if (set == null) { set = new HashSet<>(); constraints.put(constraint.getType().toLowerCase(), set); } set.add(constraint); } } }
Example #13
Source File: AnalysisEngineService_impl.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Initialize this service. This is where the CAS pool is created. * * @see org.apache.uima.resource.service.impl.ResourceService_impl#initialize(ResourceSpecifier, Map) */ public void initialize(ResourceSpecifier aResourceSpecifier, Map<String, Object> aResourceInitParams) throws ResourceInitializationException { super.initialize(aResourceSpecifier, aResourceInitParams); Integer numInstances = (Integer) aResourceInitParams .get(AnalysisEngine.PARAM_NUM_SIMULTANEOUS_REQUESTS); if (numInstances == null) { numInstances = 1; } mCasPool = new CasPool(numInstances, getAnalysisEngine()); // also record timeout period to use for CAS pool Integer timeoutInteger = (Integer) aResourceInitParams.get(AnalysisEngine.PARAM_TIMEOUT_PERIOD); if (timeoutInteger != null) { mTimeout = timeoutInteger; } else { mTimeout = 0; } }
Example #14
Source File: ConcatReader.java From bluima with Apache License 2.0 | 6 votes |
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); SingleAbstractReader r1 = new SingleAbstractReader(); r1.initialize(context); readers.add(r1); SingleAbstractReader r2 = new SingleAbstractReader(); r2.initialize(context); readers.add(r2); readersIt = readers.iterator(); currentReader = readersIt.next(); }
Example #15
Source File: AnnotationFilterAnnotator.java From bluima with Apache License 2.0 | 6 votes |
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); // validate that the class exists for (String annotationClass : annotationClasses) { try { @SuppressWarnings({ "unchecked" }) Class<? extends Annotation> classz = (Class<? extends Annotation>) Class .forName(annotationClass); checkNotNull(classz, "could not load class " + annotationClass); annotationClassesList.add(classz); } catch (Exception e) { throw new ResourceInitializationException(e); } } }
Example #16
Source File: SentimentYesNoScorer.java From bioasq with Apache License 2.0 | 6 votes |
@Override public boolean initialize(ResourceSpecifier aSpecifier, Map<String, Object> aAdditionalParams) throws ResourceInitializationException { super.initialize(aSpecifier, aAdditionalParams); String positiveWordlistPath = (String) getParameterValue("positive-wordlist-path"); String negativeWordlistPath = (String) getParameterValue("negative-wordlist-path"); try { positiveWords = Resources .readLines(getClass().getResource(positiveWordlistPath), Charsets.UTF_8).stream() .collect(toSet()); negativeWords = Resources .readLines(getClass().getResource(negativeWordlistPath), Charsets.UTF_8).stream() .collect(toSet()); } catch (IOException e) { throw new ResourceInitializationException(e); } viewNamePrefix = String.class.cast(getParameterValue("view-name-prefix")); return true; }
Example #17
Source File: MultiPageEditor.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Sets the merged type system description. * * @throws ResourceInitializationException the resource initialization exception */ public void setMergedTypeSystemDescription() throws ResourceInitializationException { mergedTypesAddingFeatures.clear(); if (isAggregate()) mergedTypeSystemDescription = mergeDelegateAnalysisEngineTypeSystems( (AnalysisEngineDescription) aeDescription.clone(), createResourceManager(), mergedTypesAddingFeatures); else { if (null == typeSystemDescription) { mergedTypeSystemDescription = null; } else { ResourceManager resourceManager = createResourceManager(); Collection tsdc = new ArrayList(1); tsdc.add(typeSystemDescription.clone()); // System.out.println("mergingTypeSystem 2"); //$NON-NLS-1$ // long time = System.currentTimeMillis(); mergedTypeSystemDescription = CasCreationUtils.mergeTypeSystems(tsdc, resourceManager, mergedTypesAddingFeatures); // System.out.println("Finished mergingTypeSystem 2; time= " + //$NON-NLS-1$ // (System.currentTimeMillis() - time)); setImportedTypeSystemDescription(); } } }
Example #18
Source File: Blacklist.java From baleen with Apache License 2.0 | 6 votes |
@Override public void doInitialize(UimaContext aContext) throws ResourceInitializationException { try { et = TypeUtils.getEntityClass( type, JCasFactory.createJCas(TypeSystemSingleton.getTypeSystemDescriptionInstance())); } catch (UIMAException | BaleenException e) { throw new ResourceInitializationException(e); } thingsToRemove = Arrays.asList(terms); if (!caseSensitive) { thingsToRemove = toLowerCase(thingsToRemove); } }
Example #19
Source File: SharedCountryResource.java From baleen with Apache License 2.0 | 5 votes |
private static JsonNode loadCountriesJson(ObjectMapper mapper, UimaMonitor uimaMonitor) throws ResourceInitializationException { try (InputStream is = SharedCountryResource.class.getResourceAsStream("countries/countries.json"); ) { return mapper.readTree(is); } catch (IOException ioe) { uimaMonitor.error("Unable to read nationalities from countries.json", ioe); throw new ResourceInitializationException(ioe); } }
Example #20
Source File: AnalysisEngineFactory_implTest.java From uima-uimaj with Apache License 2.0 | 5 votes |
public void testInvalidFrameworkImplementation() { AnalysisEngineDescription desc = new AnalysisEngineDescription_impl(); desc.setFrameworkImplementation("foo"); try { aeFactory.produceResource(AnalysisEngine.class, desc, Collections.EMPTY_MAP); fail(); } catch (ResourceInitializationException e) { assertNotNull(e.getMessage()); assertFalse(e.getMessage().startsWith("EXCEPTION MESSAGE LOCALIZATION FAILED")); assertEquals(e.getMessageKey(), ResourceInitializationException.UNSUPPORTED_FRAMEWORK_IMPLEMENTATION); } }
Example #21
Source File: CasTypeSystemMapperTst.java From uima-uimaj with Apache License 2.0 | 5 votes |
public void testCasTypeSystemMapperFull() throws ResourceInitializationException { ts1 = createTs(3, 0x1ffff, 0x1ffff); ts2 = createTs(3, 0x1ffff, 0x1ffff); // become == type systems m = new CasTypeSystemMapper(ts1, ts2); chkbase(m, t2); // check all are equal assertTrue(m.isEqual()); }
Example #22
Source File: SomeCustomResource.java From uima-uimaj with Apache License 2.0 | 5 votes |
public boolean initialize(ResourceSpecifier aSpecifier, Map aAdditionalParams) throws ResourceInitializationException { Assert.assertTrue(aSpecifier instanceof CustomResourceSpecifier); Parameter[] params = ((CustomResourceSpecifier)aSpecifier).getParameters(); for (int i = 0; i < params.length; i++) { paramMap.put(params[i].getName(), params[i].getValue()); } return true; }
Example #23
Source File: JointAidaConceptAnalysisEngine.java From ambiverse-nlu with Apache License 2.0 | 5 votes |
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); try { ds = new DisambiguationSettings.Builder().build(); } catch (MissingSettingException | NoSuchMethodException | IOException | ClassNotFoundException e) { throw new ResourceInitializationException(e); } }
Example #24
Source File: AnalysisEngineImplBase.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * @see org.apache.uima.analysis_engine.AnalysisEngine#newJCas() */ public JCas newJCas() throws ResourceInitializationException { try { return newCAS().getJCas(); } catch (CASException e) { throw new ResourceInitializationException(e); } }
Example #25
Source File: TestPearInstallationVerification.java From uima-uimaj with Apache License 2.0 | 5 votes |
private void assertThatPearInstalls(File pearFile, File targetDir) throws InvalidXMLException, ResourceInitializationException, UIMARuntimeException, UIMAException, IOException { assertThat(pearFile).as("PEAR file %s not found", pearFile).isNotNull(); // Install PEAR package without verification PackageBrowser instPear = PackageInstaller.installPackage(targetDir, pearFile, false); // Check package browser assertThat(instPear).as("PackageBrowser is null").isNotNull(); InstallationTester installTester = new InstallationTester(instPear); TestStatus status = installTester.doTest(); assertThat(status.getRetCode()).isEqualTo(TEST_SUCCESSFUL); }
Example #26
Source File: GetStartedQuickDescriptor.java From uima-uimafit with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws ResourceInitializationException, FileNotFoundException, SAXException, IOException { // uimaFIT automatically uses all type systems listed in META-INF/org.apache.uima.fit/types.txt // Instantiate the analysis engine using the value "uimaFIT" for the parameter // PARAM_STRING ("stringParam"). AnalysisEngineDescription analysisEngineDescription = AnalysisEngineFactory .createEngineDescription(GetStartedQuickAE.class, GetStartedQuickAE.PARAM_STRING, "uimaFIT"); // Write the descriptor to an XML file File output = new File("target/examples/GetStartedQuickAE.xml"); output.getParentFile().mkdirs(); analysisEngineDescription.toXML(new FileOutputStream(output)); }
Example #27
Source File: CasTypeSystemMapperTst.java From uima-uimaj with Apache License 2.0 | 5 votes |
public void testMissingType6() throws ResourceInitializationException { ts1 = createTs(0, 0x1ffff, 0x1ffff); ts1t1 = t1t; ts1t2 = t2t; ts2 = createTs(3, 0x1ffff, 0x1ffff); CasTypeSystemMapper m = new CasTypeSystemMapper(ts1, ts2); chkbase(m, t0); assertEquals(null, m.mapTypeCodeTgt2Src(t1)); assertEquals(null, m.mapTypeCodeTgt2Src(t2)); assertFalse(m.isEqual()); }
Example #28
Source File: PosTagAnnotator.java From bluima with Apache License 2.0 | 5 votes |
@Override public void initialize(UimaContext aContext) throws ResourceInitializationException { super.initialize(aContext); try { // Get OpenNLP POS Tagger, initialize with a model if (useTagdict) tagger = new PosTagger(modelFile, (Dictionary) null, new POSDictionary(tagdict, caseSensitive)); else tagger = new PosTagger(modelFile, (Dictionary) null); } catch (Exception e) { throw new ResourceInitializationException(e); } }
Example #29
Source File: PipelinesHolder.java From ambiverse-nlu with Apache License 2.0 | 5 votes |
private AnalysisEngineDescription createAnalysisEngineDescription(Component component) throws ResourceInitializationException, IOException, InvalidXMLException, NoSuchMethodException, MissingSettingException, ClassNotFoundException { AnalysisEngineDescription aed = createEngineDescription(component.component, component.params); aed.getAnalysisEngineMetaData().setName(component.name()); return aed; }
Example #30
Source File: SharedRedisResource.java From baleen with Apache License 2.0 | 5 votes |
@Override protected boolean doInitialize( final ResourceSpecifier specifier, final Map<String, Object> additionalParams) throws ResourceInitializationException { jedisPool = new JedisPool(redisServer, redisPort); getMonitor().info("Initialised Jedis resources"); return true; }