Refine search
private static Object getOptionalParameter(UimaContext context, String parameter) throws ResourceInitializationException { Object value = context.getConfigParameterValue(parameter); Logger logger = context.getLogger(); if (logger.isLoggable(Level.INFO)) { logger.log(Level.INFO, parameter + " = " + (value != null ? value.toString() : "not set")); } return value; }
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); }
public AssertionCuePhraseConsumerImpl(UimaContext aCtx, Properties props) throws Exception { // TODO property validation could be done here iv_props = props; String resrcName = iv_props.getProperty(LUCENE_FILTER_RESRC_KEY_PRP_KEY); LuceneIndexReaderResource resrc = (LuceneIndexReaderResource) aCtx.getResourceObject(resrcName); iv_searcher = new IndexSearcher(resrc.getIndexReader()); iv_maxHits = Integer.MAX_VALUE; } public void consumeHits(JCas jcas, Iterator lhItr)
@Override protected Chunker produceResource(InputStream aStream) throws Exception { ChunkerModel model = new ChunkerModel(aStream); Tagset tsdp = new OpenNlpChunkerTagsetDescriptionProvider(getResourceMetaData() .getProperty("chunk.tagset"), Chunk.class, model.getChunkerModel()); addTagset(tsdp); if (printTagSet) { getContext().getLogger().log(INFO, tsdp.toString()); } return new ChunkerME(model); } };
annotate_tokens = (Boolean) aContext.getConfigParameterValue(PARAM_ANNOTATE_TOKENS); annotate_sentences = (Boolean) aContext.getConfigParameterValue(PARAM_ANNOTATE_SENTENCES); annotate_partofspeech = (Boolean) aContext.getConfigParameterValue(PARAM_ANNOTATE_PARTOFSPEECH); model_path = (String) aContext.getConfigParameterValue(PARAM_MODEL_PATH); config_path = (String) aContext.getConfigParameterValue(PARAM_CONFIG_PATH); if(config_path != null) { // configuration exists FileInputStream isr = new FileInputStream(config_path); Properties props = new Properties(); props.load(isr); mt = new MaxentTagger(model_path, new TaggerConfig(props), false); } else { // instantiate without configuration file
Properties props = ApplicationContextHolder.getYtexProperties(); String conceptProperty = (String) aContext .getConfigParameterValue("conceptProperty"); if (!Strings.isNullOrEmpty(conceptProperty)) this.conceptProperty = conceptProperty; else this.conceptProperty = props.getProperty("ytex.conceptProperty"); Integer nWindowSize = (Integer) aContext .getConfigParameterValue("windowSize"); if (nWindowSize != null && nWindowSize.intValue() > 0) windowSize = nWindowSize.intValue(); else windowSize = Integer.parseInt(props.getProperty( "ytex.sense.windowSize", "50")); String uMetric = (String) aContext.getConfigParameterValue("metric"); if (!Strings.isNullOrEmpty(uMetric)) metric = SimilarityMetricEnum.valueOf(uMetric); else metric = SimilarityMetricEnum.valueOf(props.getProperty( "ytex.sense.metric", "INTRINSIC_PATH")); wsd = ApplicationContextHolder.getApplicationContext().getBean(
@Override protected POSTaggerME produceResource(InputStream aStream) throws Exception { // Load the POS tagger model from the location the model provider offers POSModel model = new POSModel(aStream); // end::model-provider-decl[] // Extract tagset information from the model OpenNlpTagsetDescriptionProvider tsdp = new OpenNlpTagsetDescriptionProvider( getResourceMetaData().getProperty("pos.tagset"), POS.class, model.getPosModel()); if (getResourceMetaData().containsKey("pos.tagset.tagSplitPattern")) { tsdp.setTagSplitPattern(getResourceMetaData().getProperty( "pos.tagset.tagSplitPattern")); } addTagset(tsdp); if (printTagSet) { getContext().getLogger().log(INFO, tsdp.toString()); } // tag::model-provider-decl[] // Create a new POS tagger instance from the loaded model return new POSTaggerME(model); } };
public static String[] getConfigParameterStringArrayValue(UimaContext aContext, String paramName) throws ResourceInitializationException { String[] value = (String[]) aContext.getConfigParameterValue(paramName); if (value == null) { throw new ResourceInitializationException(new IllegalArgumentException( "Must provide a parameter of type <" + paramName + ">")); } return value; }
/** * Initializes the current instance with the given context. * <p> * Note: Do all initialization in this method, do not use the constructor. */ public void initialize() throws ResourceInitializationException { super.initialize(); TokenNameFinderModel model; try { TokenNameFinderModelResource modelResource = (TokenNameFinderModelResource) context.getResourceObject(UimaUtil.MODEL_PARAMETER); model = modelResource.getModel(); } catch (ResourceAccessException e) { throw new ResourceInitializationException(e); } mNameFinder = new NameFinderME(model); }
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); } }
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); this.context = context; logger = context.getLogger(); if (logger.isLoggable(Level.INFO)) { logger.log(Level.INFO, "Initializing the OpenNLP Sentence annotator."); } isRemoveExistingAnnotations = AnnotatorUtil.getOptionalBooleanParameter( context, UimaUtil.IS_REMOVE_EXISTINGS_ANNOTAIONS); if (isRemoveExistingAnnotations == null) { isRemoveExistingAnnotations = false; } }
@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(); } }
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); } }
@Override public void initialize(UimaContext aContext) throws ResourceInitializationException { super.initialize(aContext); try { guiceInjector = (GuiceInjector) aContext.getResourceObject("guiceInjector"); labelAdapters = guiceInjector.attach().getInstance(LabelAdapters.class); } catch (ResourceAccessException e) { throw new ResourceInitializationException(e); } settingsMap = new HashMap<>(); for (String parameterName : aContext.getConfigParameterNames()) { if (parameterName != null) { settingsMap.put(parameterName, aContext.getConfigParameterValue(parameterName)); } } }
/** * Initialize the annotator, which includes compilation of regular expressions, fetching * configuration parameters from XML descriptor file, and loading of the dictionary file. */ public void initialize(UimaContext uimaContext) throws ResourceInitializationException { super.initialize(uimaContext); try { //logger = new Logger("TextTokenizer", annotatorContext.getLogger()); String[] configParameterNames = uimaContext.getConfigParameterNames(); Object[] configParameters = new Object[configParameterNames.length]; for (int i = 0; i < configParameters.length; i++) { configParameters[i] = uimaContext.getConfigParameterValue(configParameterNames[i]); } processAllConfigurationParameters(configParameterNames, configParameters); initTokenizer(configParameterNames, configParameters); } catch (Exception e) { throw new ResourceInitializationException(e); } }
private boolean getBooleanConfigParam(UimaContext aContext, String param, boolean defaultVal) { Boolean paramValue = (Boolean) aContext.getConfigParameterValue(param); return paramValue == null ? defaultVal : paramValue; }
NameFinder.NAME_TYPE_PARAMETER); String typeMapString = (String) context.getConfigParameterValue( NameFinder.NAME_TYPE_MAP_PARAMETER); mLogger.log(Level.WARNING, String.format("Failed to parse a part of the type mapping [%s]", mapping));
public boolean isInfoEnabled() { if (context != null) { Logger logger = context.getLogger(); if (logger != null) { return context.getLogger().isLoggable(Level.INFO); } } return false; }
/** * Create a configuration map from a context. * * @param context the context * @return non-empty map of config param name to config param value */ protected static Map<String, Object> getConfigParameters(UimaContext context) { Map<String, Object> ret = new HashMap<>(); for (String name : context.getConfigParameterNames()) { ret.put(name, context.getConfigParameterValue(name)); } return ret; } }