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; }
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; }
@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; } }
/** * 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); }
NameFinder.NAME_TYPE_PARAMETER); String typeMapString = (String) context.getConfigParameterValue( NameFinder.NAME_TYPE_MAP_PARAMETER); nameTypeMap.put(parts[0].trim(), typeSystem.getType(parts[1].trim())); mLogger.log(Level.WARNING, String.format("Failed to parse a part of the type mapping [%s]", mapping)); throw new AnalysisEngineProcessException( new Exception("No name type or valid name type mapping configured!"));
XMLInputSource aeIputSource = new XMLInputSource(aeDescriptorPath); ResourceSpecifier aeSpecifier = UIMAFramework.getXMLParser() .parseResourceSpecifier(aeIputSource); AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(aeSpecifier);
Logger logger = context.getLogger(); + " does not exist!"; if (logger.isLoggable(Level.WARNING)) { logger.log(Level.WARNING, message); + "running without dictionary: " + e.getMessage(); if (logger.isLoggable(Level.WARNING)) { logger.log(Level.WARNING, message);
public static AnalysisEngine produceAnalysisEngine(UimaContext c, AnalysisEngineDescription aeDesc) throws ResourceInitializationException { AnalysisEngine ae; if (c != null) { ae = UIMAFramework.produceAnalysisEngine(aeDesc, ((UimaContextAdmin) c).getResourceManager(), null); } else { ae = UIMAFramework.produceAnalysisEngine(aeDesc); } return ae; }
private void initializeResourceManager() { if (context instanceof UimaContextAdmin) { UimaContextAdmin uca = (UimaContextAdmin) context; ResourceManager rm = uca.getResourceManager(); if (rm != null) { resourceManager = rm; } } if (resourceManager == null) { resourceManager = UIMAFramework.newDefaultResourceManager(); } }
/** * Creates the fs index key description. * * @return the fs index key description */ public FsIndexKeyDescription createFsIndexKeyDescription() { return UIMAFramework.getResourceSpecifierFactory().createFsIndexKeyDescription(); }
@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 " + name + " annotator."); } isRemoveExistingAnnotations = AnnotatorUtil.getOptionalBooleanParameter( context, UimaUtil.IS_REMOVE_EXISTINGS_ANNOTAIONS); if (isRemoveExistingAnnotations == null) { isRemoveExistingAnnotations = false; } }
/** * 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 final 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 " + name + "."); } isRemoveExistingAnnotations = AnnotatorUtil.getOptionalBooleanParameter( context, UimaUtil.IS_REMOVE_EXISTINGS_ANNOTAIONS); if (isRemoveExistingAnnotations == null) { isRemoveExistingAnnotations = false; } initialize(); }
/** * 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); }
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. * <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); }
/** * 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); }
/** * 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 Normalizer annotator."); } try { String modelName = AnnotatorUtil.getOptionalStringParameter(context, UimaUtil.DICTIONARY_PARAMETER); if (modelName != null) { InputStream inModel = AnnotatorUtil.getResourceAsStream(context, modelName); mLookupDictionary = new StringDictionary(inModel); } } catch (IOException e) { throw new ResourceInitializationException( ExceptionMessages.MESSAGE_CATALOG, "io_error_model_reading", new Object[] {e.getMessage()}, e); } }