/** * 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); }
/** * 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); }
/** * 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); TokenizerModel model; try { TokenizerModelResource modelResource = (TokenizerModelResource) context .getResourceObject(UimaUtil.MODEL_PARAMETER); model = modelResource.getModel(); } catch (ResourceAccessException e) { throw new ResourceInitializationException(e); } tokenizer = new TokenizerME(model); }
/** * 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 { Dictionary nameFinderDictionary; try { DictionaryResource modelResource = (DictionaryResource) context .getResourceObject(UimaUtil.DICTIONARY_PARAMETER); nameFinderDictionary = modelResource.getDictionary(); } catch (ResourceAccessException e) { try { String modelName = AnnotatorUtil.getRequiredStringParameter(context, UimaUtil.DICTIONARY_PARAMETER); InputStream inModel = AnnotatorUtil.getResourceAsStream(context, modelName); nameFinderDictionary = new Dictionary(inModel); } catch (IOException ie) { throw new ResourceInitializationException( ExceptionMessages.MESSAGE_CATALOG, ExceptionMessages.IO_ERROR_DICTIONARY_READING, new Object[] {ie.getMessage()}); } } mNameFinder = new opennlp.tools.namefind.DictionaryNameFinder( nameFinderDictionary); }
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); }
/** * Initializes the current instance with the given context. */ public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); this.context = context; mLogger = context.getLogger(); if (mLogger.isLoggable(Level.INFO)) { mLogger.log(Level.INFO, "Initializing the OpenNLP Parser."); } ParserModel model; try { ParserModelResource modelResource = (ParserModelResource) context .getResourceObject(UimaUtil.MODEL_PARAMETER); model = modelResource.getModel(); } catch (ResourceAccessException e) { throw new ResourceInitializationException(e); } mParser = ParserFactory.create(model); }
/** * 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); this.context = context; mLogger = context.getLogger(); if (mLogger.isLoggable(Level.INFO)) { mLogger.log(Level.INFO, "Initializing the OpenNLP Chunker annotator."); } ChunkerModel model; try { ChunkerModelResource modelResource = (ChunkerModelResource) context.getResourceObject(UimaUtil.MODEL_PARAMETER); model = modelResource.getModel(); } catch (ResourceAccessException e) { throw new ResourceInitializationException(e); } mChunker = new ChunkerME(model); }
/** * Initializes the current instance with the given context. * <p> * Note: Do all initialization in this method, do not use the constructor. */ @Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); this.context = context; this.logger = context.getLogger(); if (this.logger.isLoggable(Level.INFO)) { this.logger.log(Level.INFO, "Initializing the OpenNLP " + "Part of Speech annotator."); } POSModel model; try { POSModelResource modelResource = (POSModelResource) context .getResourceObject(UimaUtil.MODEL_PARAMETER); model = modelResource.getModel(); } catch (ResourceAccessException e) { throw new ResourceInitializationException(e); } Integer beamSize = AnnotatorUtil.getOptionalIntegerParameter(context, UimaUtil.BEAM_SIZE_PARAMETER); if (beamSize == null) { beamSize = POSTaggerME.DEFAULT_BEAM_SIZE; } this.posTagger = new POSTaggerME(model); }
/** * {@inheritDoc} */ @Override public Object getResourceObject( final String name, String[] params ) throws ResourceAccessException { return _delegate.getResourceObject( name, params ); }
private static Object getResourceObject(UimaContext aContext, String aKey) throws ResourceInitializationException { Object value; try { value = aContext.getResourceObject(aKey); } catch (ResourceAccessException e) { throw new ResourceInitializationException(e); } return value; }
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 UmlsToSnomedDbConsumerImpl( final UimaContext uimaContext, final Properties properties, final int maxListSize ) throws Exception { super( uimaContext, properties ); _maxListSize = maxListSize; final String resourceName = props.getProperty( DB_CONN_RESRC_KEY_PRP_KEY ); final JdbcConnectionResource resrc = (JdbcConnectionResource) uimaContext.getResourceObject( resourceName ); final String sqlStatement = props.getProperty( MAP_PREP_STMT_PRP_KEY ); final Connection connection = resrc.getConnection(); _preparedStatement = connection.prepareStatement( sqlStatement ); }
public OrangeBookFilterConsumerImpl( final UimaContext aCtx, final Properties props, final int maxListSize ) throws ResourceAccessException, NullPointerException { // TODO property validation could be done here _properties = props; _maxListSize = maxListSize; final String resrcName = _properties.getProperty( LUCENE_FILTER_RESRC_KEY_PRP_KEY ); // UimaContext.getResourceObject(..) throws ResourceAccessException final LuceneIndexReaderResource resrc = (LuceneIndexReaderResource) aCtx.getResourceObject( resrcName ); // Possible npE with resrc.getIndexReader() _indexSearcher = new IndexSearcher( resrc.getIndexReader() ); }
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)
public OrangeBookFilterConsumerImpl( final UimaContext aCtx, final Properties props, final int maxListSize ) throws ResourceAccessException, NullPointerException { // TODO property validation could be done here _properties = props; _maxListSize = maxListSize; final String resrcName = _properties.getProperty( LUCENE_FILTER_RESRC_KEY_PRP_KEY ); // UimaContext.getResourceObject(..) throws ResourceAccessException final LuceneIndexReaderResource resrc = (LuceneIndexReaderResource) aCtx.getResourceObject( resrcName ); // Possible npE with resrc.getIndexReader() _indexSearcher = new IndexSearcher( resrc.getIndexReader() ); }
public AssertionCuePhraseConsumerImpl(UimaContext aCtx, Properties props, int maxListSize) throws Exception { // TODO property validation could be done here iv_props = props; iv_maxHits = maxListSize; String resrcName = iv_props.getProperty(LUCENE_FILTER_RESRC_KEY_PRP_KEY); LuceneIndexReaderResource resrc = (LuceneIndexReaderResource) aCtx.getResourceObject(resrcName); iv_searcher = new IndexSearcher(resrc.getIndexReader()); } public AssertionCuePhraseConsumerImpl(UimaContext aCtx, Properties props)
public AssertionCuePhraseConsumerImpl(UimaContext aCtx, Properties props, int maxListSize) throws Exception { // TODO property validation could be done here iv_props = props; iv_maxHits = maxListSize; String resrcName = iv_props.getProperty(LUCENE_FILTER_RESRC_KEY_PRP_KEY); LuceneIndexReaderResource resrc = (LuceneIndexReaderResource) aCtx.getResourceObject(resrcName); iv_searcher = new IndexSearcher(resrc.getIndexReader()); } public AssertionCuePhraseConsumerImpl(UimaContext aCtx, Properties props)
@Override public void initialize(UimaContext aContext) throws ResourceInitializationException { super.initialize(aContext); try { dbUtilsProvider = (DBUtilsProvider) aContext.getResourceObject(RESOURCE_TRAINED_DB); trainedDb = dbUtilsProvider.getTrainedDatabase(); } catch (ResourceAccessException e) { throw new ResourceInitializationException(e); } loader = new DataLoader(); }
private ModelGeneration get_model() throws AnnotatorConfigurationException { IModelResource modelResource = null; try { modelResource = (IModelResource) getContext().getResourceObject(model_file_param); } catch (Exception e) { throw new AnnotatorConfigurationException(e); } return modelResource.getModel(); }
@Before public void beforeMongoRecordConsumerTest() throws ResourceInitializationException, ResourceAccessException { mongoExternalResourceDescription = ExternalResourceFactory.createExternalResourceDescription( MONGO, SharedFongoResource.class, "fongo.collection", "test", "fongo.data", "[]"); analysisEngine = getAnalysisEngine("mongo", mongoExternalResourceDescription, "collection", "test"); SharedFongoResource sfr = (SharedFongoResource) analysisEngine.getUimaContext().getResourceObject(MONGO); recordsCollection = sfr.getDB().getCollection("records"); }