Java Code Examples for org.apache.uima.UimaContext#getConfigParameterValue()
The following examples show how to use
org.apache.uima.UimaContext#getConfigParameterValue() .
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: RoomNumberAnnotator.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * @see AnalysisComponent#initialize(UimaContext) */ public void initialize(UimaContext aContext) throws ResourceInitializationException { super.initialize(aContext); // Get config. parameter values String[] patternStrings = (String[]) aContext.getConfigParameterValue("Patterns"); mLocations = (String[]) aContext.getConfigParameterValue("Locations"); // compile regular expressions mPatterns = new Pattern[patternStrings.length]; for (int i = 0; i < patternStrings.length; i++) { try { mPatterns[i] = Pattern.compile(patternStrings[i]); } catch (PatternSyntaxException e) { throw new ResourceInitializationException(MESSAGE_DIGEST, "regex_syntax_error", new Object[] { patternStrings[i] }, e); } } }
Example 2
Source File: StaticConfiguration.java From bluima with Apache License 2.0 | 6 votes |
@Override /** dynamically loading parameters (names = "o1", "o2", ...)*/ public void initialize(UimaContext ctx) throws ResourceInitializationException { super.initialize(ctx); checkArgument(ctx.getConfigParameterNames().length > 0, "there should at least be one config parameter set"); List<String> optionsStr = newArrayList(); for (String paramName : ctx.getConfigParameterNames()) { String param = (String) ctx.getConfigParameterValue(paramName); optionsStr.add(param); } StaticOption.parseConfiguration(optionsStr); }
Example 3
Source File: AnnotationInsertingWriter.java From biomedicus with Apache License 2.0 | 6 votes |
@Override public void initialize(UimaContext aContext) throws ResourceInitializationException { super.initialize(aContext); annotationTypes = (String[]) aContext.getConfigParameterValue("annotationTypes"); outputDir = Paths.get((String) aContext.getConfigParameterValue("outputDirectory")); try { Files.createDirectories(outputDir); } catch (IOException e) { throw new ResourceInitializationException(e); } documentName = ((String) aContext.getConfigParameterValue("documentName")); rtfDocumentName = ((String) aContext.getConfigParameterValue("rtfDocumentName")); }
Example 4
Source File: GridSearchConfiguration.java From bluima with Apache License 2.0 | 6 votes |
@Override public void initialize(UimaContext ctx) throws ResourceInitializationException { super.initialize(ctx); // dynamically loading parameters (names = "o1", "o2", ...) checkArgument(newArrayList(ctx.getConfigParameterNames()) .contains("o1"), "there should at least be 'o1'"); List<String> optionsStr = newArrayList(); for (int i = 1; i < ctx.getConfigParameterNames().length; i++) { String param = (String) ctx.getConfigParameterValue("o" + i); optionsStr.add(param); } StaticOption.parseOptions(optionsStr); // from combinaisonIndex, find current option StaticOption.setChoosenOption(combinaisonIndex); StaticOption.print(); }
Example 5
Source File: ViewMigratorJCasMultiplier.java From biomedicus with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} <p>Initializes the 3 parameters, "sourceViewName", "targetViewName", and * "deleteOriginalView".</p> */ @Override public void initialize(UimaContext aContext) throws ResourceInitializationException { super.initialize(aContext); sourceViewName = (String) aContext.getConfigParameterValue(PARAM_SOURCE_VIEW_NAME); targetViewName = (String) aContext.getConfigParameterValue(PARAM_TARGET_VIEW_NAME); deleteOriginalView = (Boolean) aContext.getConfigParameterValue(PARAM_DELETE_ORIGINAL_VIEW); try { String className = (String) aContext.getConfigParameterValue(PARAM_VIEW_MIGRATOR_CLASS); viewMigratorClass = Class.forName(className).asSubclass(ViewMigrator.class); } catch (ClassNotFoundException e) { throw new ResourceInitializationException(e); } }
Example 6
Source File: UimaUtils.java From baleen with Apache License 2.0 | 5 votes |
/** * Should we merge distinct entities or not, based on the global configuration parameter * <em>history.mergeDistinctEntities</em> (unless overridden locally) * * @param context * @return true if we should, false otherwise */ public static boolean isMergeDistinctEntities(UimaContext context) { Object value = context.getConfigParameterValue(BaleenHistoryConstants.MERGE_DISTINCT_ENTITIES); if (value == null || !(value instanceof Boolean)) { return false; } else { return (boolean) value; } }
Example 7
Source File: UimaContextFactoryTest.java From uima-uimafit with Apache License 2.0 | 5 votes |
@Test public void test() throws ResourceInitializationException { UimaContext context = UimaContextFactory .createUimaContext("myBoolean", true, "myBooleans", new Boolean[] { true, false, true, false }, "myFloat", 1.0f, "myFloats", new Float[] { 2.0f, 2.1f, 3.0f }, "myInt", 1, "myInts", new Integer[] { 2, 3, 4 }, "myString", "yourString", "myStrings", new String[] { "yourString1", "yourString2", "yourString3" }); assertEquals(true, context.getConfigParameterValue("myBoolean")); Boolean[] myBooleans = (Boolean[]) context.getConfigParameterValue("myBooleans"); assertEquals(4, myBooleans.length); assertEquals(true, myBooleans[0]); assertEquals(false, myBooleans[1]); assertEquals(true, myBooleans[2]); assertEquals(false, myBooleans[3]); assertEquals(1.0f, context.getConfigParameterValue("myFloat")); Float[] myFloats = (Float[]) context.getConfigParameterValue("myFloats"); assertEquals(3, myFloats.length); assertEquals(2.0d, myFloats[0].doubleValue(), 0.001d); assertEquals(2.1d, myFloats[1].doubleValue(), 0.001d); assertEquals(3.0d, myFloats[2].doubleValue(), 0.001d); assertEquals(1, context.getConfigParameterValue("myInt")); Integer[] myInts = (Integer[]) context.getConfigParameterValue("myInts"); assertEquals(3, myInts.length); assertEquals(2L, myInts[0].longValue()); assertEquals(3L, myInts[1].longValue()); assertEquals(4L, myInts[2].longValue()); assertEquals("yourString", context.getConfigParameterValue("myString")); String[] myStrings = (String[]) context.getConfigParameterValue("myStrings"); assertEquals(3, myStrings.length); assertEquals("yourString1", myStrings[0]); assertEquals("yourString2", myStrings[1]); assertEquals("yourString3", myStrings[2]); }
Example 8
Source File: Conll2003ReaderTcBmeow.java From ambiverse-nlu with Apache License 2.0 | 5 votes |
private Object[] getConfigurationParams(UimaContext aContext) { Object[] params = new Object[aContext.getConfigParameterNames().length * 2]; int i = 0; for (String name : aContext.getConfigParameterNames()) { params[2*i] = name; params[2*i+1] = aContext.getConfigParameterValue(name); i++; } return params; }
Example 9
Source File: UimaUtils.java From baleen with Apache License 2.0 | 5 votes |
/** * Get the name of the pipeline which owns this context. This is set in {@link PipelineBuilder}. * * @param context * @return the pipeline name or "unknown" */ public static String getPipelineName(UimaContext context) { Object pipelineNameValue = context.getConfigParameterValue(PipelineBuilder.PIPELINE_NAME); String pipelineName; if (pipelineNameValue == null || !(pipelineNameValue instanceof String)) { pipelineName = "unknown"; } else { pipelineName = (String) pipelineNameValue; } return pipelineName; }
Example 10
Source File: RtfParserAnnotator.java From biomedicus with Apache License 2.0 | 5 votes |
@Override public void initialize(UimaContext aContext) throws ResourceInitializationException { super.initialize(aContext); LOGGER.info("initializing rtf parser"); String rtfPropertiesDesc = (String) aContext.getConfigParameterValue(PARAM_RTF_PROPERTIES_DESC); String rtfControlKeywordsDesc = (String) aContext .getConfigParameterValue(PARAM_RTF_CONTROL_KEYWORDS_DESC); String rtfCasMappingsDesc = (String) aContext .getConfigParameterValue(PARAM_RTF_CAS_MAPPINGS_DESC); Boolean writeTables = (Boolean) aContext.getConfigParameterValue(PARAM_WRITE_TABLES); rtfParserFactory = RtfParserFactory.createByLoading( rtfPropertiesDesc, rtfControlKeywordsDesc, rtfCasMappingsDesc, writeTables ); originalDocumentViewName = (String) aContext .getConfigParameterValue(PARAM_ORIGINAL_DOCUMENT_VIEW_NAME); targetViewName = (String) aContext.getConfigParameterValue(PARAM_TARGET_VIEW_NAME); }
Example 11
Source File: MigratorEngine.java From biomedicus with Apache License 2.0 | 5 votes |
@Override public void initialize(UimaContext aContext) throws ResourceInitializationException { super.initialize(aContext); String migrationClassName = (String) aContext.getConfigParameterValue("migration"); try { migration = Class.forName(migrationClassName).asSubclass(TypeSystemMigration.class) .newInstance(); Preconditions.checkNotNull(migration); } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { throw new ResourceInitializationException(e); } }
Example 12
Source File: Conll2003ReaderTc.java From ambiverse-nlu with Apache License 2.0 | 5 votes |
private Object[] getConfigurationParams(UimaContext aContext) { Object[] params = new Object[aContext.getConfigParameterNames().length * 2]; int i = 0; for (String name : aContext.getConfigParameterNames()) { params[2*i] = name; params[2*i+1] = aContext.getConfigParameterValue(name); i++; } return params; }
Example 13
Source File: TableAnnotator.java From biomedicus with Apache License 2.0 | 4 votes |
@Override public void initialize(UimaContext aContext) throws ResourceInitializationException { super.initialize(aContext); documentName = ((String) aContext.getConfigParameterValue("documentName")); }
Example 14
Source File: ParagraphAnnotator.java From biomedicus with Apache License 2.0 | 4 votes |
@Override public void initialize(UimaContext aContext) throws ResourceInitializationException { super.initialize(aContext); documentName = ((String) aContext.getConfigParameterValue("documentName")); }
Example 15
Source File: ParseAnnotator.java From bluima with Apache License 2.0 | 4 votes |
@Override public void initialize(UimaContext aContext) throws ResourceInitializationException { System.out.println("initializing OpenNLP Parse Annotator ..."); super.initialize(aContext); /** * Initialize parameters * */ model = (String) aContext.getConfigParameterValue("modelDir"); tagSet = (String) aContext.getConfigParameterValue("tagset"); useTagdict = ((Boolean) aContext.getConfigParameterValue("useTagdict")) .booleanValue(); caseSensitive = ((Boolean) aContext .getConfigParameterValue("caseSensitive")).booleanValue(); fun = ((Boolean) aContext.getConfigParameterValue("fun")) .booleanValue(); mappings = (String[]) aContext.getConfigParameterValue("mappings"); loadMappings(); if (aContext.getConfigParameterValue("beamSize") != null) beamSize = ((Integer) aContext.getConfigParameterValue("beamSize")) .intValue(); if (aContext.getConfigParameterValue("advancePercentage") != null) advancePercentage = new Double((String) aContext .getConfigParameterValue("advancePercentage")) .doubleValue(); initBracketMap(); initFunMap(); // Initialize Parser try { parser = TreebankParser.getParser(model, useTagdict, caseSensitive, beamSize, advancePercentage); } catch (IOException e) { LOGGER.error("[OpenNLP Parser] Could not load Parser models: " + e.getMessage()); e.printStackTrace(); } }
Example 16
Source File: HeidelTimeOpenNLP.java From newsleak with GNU Affero General Public License v3.0 | 4 votes |
/** * @see AnalysisComponent#initialize(UimaContext) */ public void initialize(UimaContext aContext) throws ResourceInitializationException { super.initialize(aContext); ///////////////////////////////// // DEBUGGING PARAMETER SETTING // ///////////////////////////////// this.deleteOverlapped = true; Boolean doDebug = (Boolean) aContext.getConfigParameterValue(PARAM_DEBUG); Logger.setPrintDetails(doDebug == null ? false : doDebug); ///////////////////////////////// // HANDLE LOCALE // ///////////////////////////////// if (requestedLocale == null || requestedLocale.length() == 0) { // if // the // PARAM_LOCALE // setting // was // left // empty, Locale.setDefault(Locale.UK); // use a default, the ISO8601-adhering // UK locale (equivalent to "en_GB") } else { // otherwise, check if the desired locale exists in the JVM's // available locale repertoire try { Locale locale = DateCalculator.getLocaleFromString(requestedLocale); Locale.setDefault(locale); // sets it for the entire JVM session } catch (LocaleException e) { Logger.printError( "Supplied locale parameter couldn't be resolved to a working locale. Try one of these:"); String localesString = new String(); for (Locale l : Locale.getAvailableLocales()) { // list all // available // locales localesString += l.toString() + " "; } Logger.printError(localesString); System.exit(-1); } } ////////////////////////////////// // GET CONFIGURATION PARAMETERS // ////////////////////////////////// language = Language.getLanguageFromString(requestedLanguage); // typeToProcess = (String) // aContext.getConfigParameterValue(PARAM_TYPE_TO_PROCESS); // find_dates = (Boolean) aContext.getConfigParameterValue(PARAM_DATE); // find_times = (Boolean) aContext.getConfigParameterValue(PARAM_TIME); // find_durations = (Boolean) // aContext.getConfigParameterValue(PARAM_DURATION); // find_sets = (Boolean) aContext.getConfigParameterValue(PARAM_SET); // find_temponyms = (Boolean) // aContext.getConfigParameterValue(PARAM_TEMPONYMS); // group_gran = (Boolean) aContext.getConfigParameterValue(PARAM_GROUP); //////////////////////////////////////////////////////////// // READ NORMALIZATION RESOURCES FROM FILES AND STORE THEM // //////////////////////////////////////////////////////////// NormalizationManager.getInstance(language, find_temponyms); ////////////////////////////////////////////////////// // READ PATTERN RESOURCES FROM FILES AND STORE THEM // ////////////////////////////////////////////////////// RePatternManager.getInstance(language, find_temponyms); /////////////////////////////////////////////////// // READ RULE RESOURCES FROM FILES AND STORE THEM // /////////////////////////////////////////////////// RuleManager.getInstance(language, find_temponyms); ///////////////////////////////////////////////////////////////////////////////// // SUBPROCESSOR CONFIGURATION. REGISTER YOUR OWN PROCESSORS HERE FOR ///////////////////////////////////////////////////////////////////////////////// EXECUTION ///////////////////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////////////////// procMan.registerProcessor("de.unihd.dbs.uima.annotator.heideltime.processors.HolidayProcessor"); procMan.registerProcessor("de.unihd.dbs.uima.annotator.heideltime.processors.DecadeProcessor"); procMan.initializeAllProcessors(aContext); ///////////////////////////// // PRINT WHAT WILL BE DONE // ///////////////////////////// if (find_dates) Logger.printDetail("Getting Dates..."); if (find_times) Logger.printDetail("Getting Times..."); if (find_durations) Logger.printDetail("Getting Durations..."); if (find_sets) Logger.printDetail("Getting Sets..."); if (find_temponyms) Logger.printDetail("Getting Temponyms..."); }
Example 17
Source File: AnnotatorForCollectionProcessCompleteTest.java From uima-uimaj with Apache License 2.0 | 4 votes |
public void initialize(UimaContext aContext) throws ResourceInitializationException { super.initialize(aContext); testValue = (String)aContext.getConfigParameterValue("TestValue"); }
Example 18
Source File: SimpleTextMerger.java From uima-uimaj with Apache License 2.0 | 4 votes |
public void initialize(UimaContext aContext) throws ResourceInitializationException { super.initialize(aContext); mAnnotationTypesToCopy = (String[]) aContext.getConfigParameterValue("AnnotationTypesToCopy"); }
Example 19
Source File: SimpleTextSegmenter.java From uima-uimaj with Apache License 2.0 | 4 votes |
public void initialize(UimaContext aContext) throws ResourceInitializationException { super.initialize(aContext); mSegmentSize = (Integer) aContext.getConfigParameterValue("SegmentSize"); }
Example 20
Source File: MeetingAnnotator.java From uima-uimaj with Apache License 2.0 | 4 votes |
/** * @see AnalysisComponent#initialize(UimaContext) */ public void initialize(UimaContext aContext) throws ResourceInitializationException { super.initialize(aContext); // Get config. parameter value mWindowSize = (Integer) aContext.getConfigParameterValue("WindowSize"); }