org.apache.uima.util.Logger.log()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(142)

本文整理了Java中org.apache.uima.util.Logger.log()方法的一些代码示例,展示了Logger.log()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.log()方法的具体详情如下:
包路径:org.apache.uima.util.Logger
类名称:Logger
方法名:log

Logger.log介绍

[英]Logs a message.
[中]记录一条消息。

代码示例

代码示例来源:origin: apache/opennlp

  1. private static Object getOptionalParameter(UimaContext context,
  2. String parameter)
  3. throws ResourceInitializationException {
  4. Object value = context.getConfigParameterValue(parameter);
  5. Logger logger = context.getLogger();
  6. if (logger.isLoggable(Level.INFO)) {
  7. logger.log(Level.INFO, parameter + " = " +
  8. (value != null ? value.toString() : "not set"));
  9. }
  10. return value;
  11. }

代码示例来源:origin: apache/opennlp

  1. mLogger.log(Level.WARNING,
  2. String.format("Failed to parse a part of the type mapping [%s]", mapping));

代码示例来源:origin: apache/opennlp

  1. this.logger.log(Level.FINER, sentenceWithPos.toString());

代码示例来源:origin: apache/opennlp

  1. logger.log(Level.WARNING, message);
  2. logger.log(Level.WARNING, message);

代码示例来源:origin: apache/opennlp

  1. @Override
  2. public void initialize(UimaContext context)
  3. throws ResourceInitializationException {
  4. super.initialize(context);
  5. this.context = context;
  6. logger = context.getLogger();
  7. if (logger.isLoggable(Level.INFO)) {
  8. logger.log(Level.INFO, "Initializing the OpenNLP Sentence annotator.");
  9. }
  10. isRemoveExistingAnnotations = AnnotatorUtil.getOptionalBooleanParameter(
  11. context, UimaUtil.IS_REMOVE_EXISTINGS_ANNOTAIONS);
  12. if (isRemoveExistingAnnotations == null) {
  13. isRemoveExistingAnnotations = false;
  14. }
  15. }

代码示例来源:origin: apache/opennlp

  1. @Override
  2. public void initialize(UimaContext context)
  3. throws ResourceInitializationException {
  4. super.initialize(context);
  5. this.context = context;
  6. logger = context.getLogger();
  7. if (logger.isLoggable(Level.INFO)) {
  8. logger.log(Level.INFO, "Initializing the " + name + " annotator.");
  9. }
  10. isRemoveExistingAnnotations = AnnotatorUtil.getOptionalBooleanParameter(
  11. context, UimaUtil.IS_REMOVE_EXISTINGS_ANNOTAIONS);
  12. if (isRemoveExistingAnnotations == null) {
  13. isRemoveExistingAnnotations = false;
  14. }
  15. }

代码示例来源:origin: apache/opennlp

  1. public void initialize(UimaContext context)
  2. throws ResourceInitializationException {
  3. super.initialize(context);
  4. this.context = context;
  5. Logger mLogger = context.getLogger();
  6. if (mLogger.isLoggable(Level.INFO)) {
  7. mLogger.log(Level.INFO, "Initializing the OpenNLP Categorizer.");
  8. }
  9. DoccatModel model;
  10. try {
  11. DoccatModelResource modelResource = (DoccatModelResource) context
  12. .getResourceObject(UimaUtil.MODEL_PARAMETER);
  13. model = modelResource.getModel();
  14. } catch (ResourceAccessException e) {
  15. throw new ResourceInitializationException(e);
  16. }
  17. mCategorizer = new DocumentCategorizerME(model);
  18. }

代码示例来源:origin: apache/opennlp

  1. /**
  2. * Initializes the current instance with the given context.
  3. * <p>
  4. * Note: Do all initialization in this method, do not use the constructor.
  5. */
  6. public void initialize(UimaContext context)
  7. throws ResourceInitializationException {
  8. super.initialize(context);
  9. this.context = context;
  10. mLogger = context.getLogger();
  11. if (mLogger.isLoggable(Level.INFO)) {
  12. mLogger.log(Level.INFO, "Initializing the OpenNLP Normalizer annotator.");
  13. }
  14. try {
  15. String modelName = AnnotatorUtil.getOptionalStringParameter(context,
  16. UimaUtil.DICTIONARY_PARAMETER);
  17. if (modelName != null) {
  18. InputStream inModel = AnnotatorUtil.getResourceAsStream(context,
  19. modelName);
  20. mLookupDictionary = new StringDictionary(inModel);
  21. }
  22. } catch (IOException e) {
  23. throw new ResourceInitializationException(
  24. ExceptionMessages.MESSAGE_CATALOG, "io_error_model_reading",
  25. new Object[] {e.getMessage()}, e);
  26. }
  27. }

代码示例来源:origin: apache/opennlp

  1. public final void initialize(UimaContext context) throws ResourceInitializationException {
  2. super.initialize(context);
  3. this.context = context;
  4. mLogger = context.getLogger();
  5. if (mLogger.isLoggable(Level.INFO)) {
  6. mLogger.log(Level.INFO, "Initializing the " + name + ".");
  7. }
  8. isRemoveExistingAnnotations = AnnotatorUtil.getOptionalBooleanParameter(
  9. context, UimaUtil.IS_REMOVE_EXISTINGS_ANNOTAIONS);
  10. if (isRemoveExistingAnnotations == null) {
  11. isRemoveExistingAnnotations = false;
  12. }
  13. initialize();
  14. }

代码示例来源:origin: apache/opennlp

  1. /**
  2. * Initializes the current instance with the given context.
  3. */
  4. public void initialize(UimaContext context)
  5. throws ResourceInitializationException {
  6. super.initialize(context);
  7. this.context = context;
  8. mLogger = context.getLogger();
  9. if (mLogger.isLoggable(Level.INFO)) {
  10. mLogger.log(Level.INFO, "Initializing the OpenNLP Parser.");
  11. }
  12. ParserModel model;
  13. try {
  14. ParserModelResource modelResource = (ParserModelResource) context
  15. .getResourceObject(UimaUtil.MODEL_PARAMETER);
  16. model = modelResource.getModel();
  17. } catch (ResourceAccessException e) {
  18. throw new ResourceInitializationException(e);
  19. }
  20. mParser = ParserFactory.create(model);
  21. }

代码示例来源:origin: apache/opennlp

  1. tokeninzedSentenceLog.length() - 1);
  2. logger.log(Level.FINER, "\"" + tokeninzedSentenceLog.toString() + "\"");

代码示例来源:origin: apache/opennlp

  1. /**
  2. * Initializes the current instance with the given context.
  3. * <p>
  4. * Note: Do all initialization in this method, do not use the constructor.
  5. */
  6. public void initialize(UimaContext context)
  7. throws ResourceInitializationException {
  8. super.initialize(context);
  9. this.context = context;
  10. mLogger = context.getLogger();
  11. if (mLogger.isLoggable(Level.INFO)) {
  12. mLogger.log(Level.INFO, "Initializing the OpenNLP Chunker annotator.");
  13. }
  14. ChunkerModel model;
  15. try {
  16. ChunkerModelResource modelResource =
  17. (ChunkerModelResource) context.getResourceObject(UimaUtil.MODEL_PARAMETER);
  18. model = modelResource.getModel();
  19. } catch (ResourceAccessException e) {
  20. throw new ResourceInitializationException(e);
  21. }
  22. mChunker = new ChunkerME(model);
  23. }

代码示例来源:origin: apache/opennlp

  1. protected void process(CAS cas, AnnotationFS sentenceAnnotation) {
  2. FSIndex<AnnotationFS> allTokens = cas.getAnnotationIndex(mTokenType);
  3. ContainingConstraint containingConstraint =
  4. new ContainingConstraint(sentenceAnnotation);
  5. String sentence = sentenceAnnotation.getCoveredText();
  6. Iterator<AnnotationFS> containingTokens = cas.createFilteredIterator(
  7. allTokens.iterator(), containingConstraint);
  8. List<Span> tokenSpans = new LinkedList<>();
  9. while (containingTokens.hasNext()) {
  10. AnnotationFS token = containingTokens.next();
  11. tokenSpans.add(new Span(token.getBegin() - sentenceAnnotation.getBegin(),
  12. token.getEnd() - sentenceAnnotation.getBegin()));
  13. }
  14. ParseConverter converter = new ParseConverter(sentence, tokenSpans.toArray(new Span[tokenSpans.size()]));
  15. Parse unparsedTree = converter.getParseForTagger();
  16. if (unparsedTree.getChildCount() > 0) {
  17. Parse parse = mParser.parse(unparsedTree);
  18. // TODO: We need a strategy to handle the case that a full
  19. // parse could not be found. What to do in this case?
  20. parse = converter.transformParseFromTagger(parse);
  21. if (mLogger.isLoggable(Level.INFO)) {
  22. StringBuffer parseString = new StringBuffer();
  23. parse.show(parseString);
  24. mLogger.log(Level.INFO, parseString.toString());
  25. }
  26. createAnnotation(cas, sentenceAnnotation.getBegin(), parse);
  27. }
  28. }

代码示例来源:origin: apache/opennlp

  1. /**
  2. * Initializes the current instance with the given context.
  3. * <p>
  4. * Note: Do all initialization in this method, do not use the constructor.
  5. */
  6. @Override
  7. public void initialize(UimaContext context)
  8. throws ResourceInitializationException {
  9. super.initialize(context);
  10. this.context = context;
  11. this.logger = context.getLogger();
  12. if (this.logger.isLoggable(Level.INFO)) {
  13. this.logger.log(Level.INFO, "Initializing the OpenNLP "
  14. + "Part of Speech annotator.");
  15. }
  16. POSModel model;
  17. try {
  18. POSModelResource modelResource = (POSModelResource) context
  19. .getResourceObject(UimaUtil.MODEL_PARAMETER);
  20. model = modelResource.getModel();
  21. } catch (ResourceAccessException e) {
  22. throw new ResourceInitializationException(e);
  23. }
  24. Integer beamSize = AnnotatorUtil.getOptionalIntegerParameter(context,
  25. UimaUtil.BEAM_SIZE_PARAMETER);
  26. if (beamSize == null) {
  27. beamSize = POSTaggerME.DEFAULT_BEAM_SIZE;
  28. }
  29. this.posTagger = new POSTaggerME(model);
  30. }

代码示例来源:origin: apache/opennlp

  1. mLogger.log(Level.INFO, "Unsupported language: " + language);
  2. } catch (ParseException e) {
  3. if (mLogger.isLoggable(Level.INFO)) {
  4. mLogger.log(Level.INFO, "Invalid number format: " + text);

代码示例来源:origin: apache/opennlp

  1. logger.log(Level.FINER, "\"" + sentences[i].getCoveredText() + "\"");

代码示例来源:origin: org.apache.uima/uimafit-core

  1. public void log(Level level, String aMessage, Object[] params) {
  2. if (context != null) {
  3. Logger logger = context.getLogger();
  4. if (logger != null && logger.isLoggable(level)) {
  5. String result = MessageFormat.format(aMessage, params);
  6. logger.log(getClass().getName(), level, result, null);
  7. }
  8. }
  9. }

代码示例来源:origin: org.apache.uima/uimafit-core

  1. public void log(Level level, String aMessage, Throwable thrown) {
  2. if (context != null) {
  3. Logger logger = context.getLogger();
  4. if (logger != null && logger.isLoggable(level)) {
  5. logger.log(getClass().getName(), level, aMessage, thrown);
  6. }
  7. }
  8. }

代码示例来源:origin: org.apache.uima/uimafit-core

  1. public void logrb(Level level, String sourceClass, String sourceMethod, String bundleName,
  2. String msgKey, Object[] params) {
  3. if (context != null) {
  4. Logger logger = context.getLogger();
  5. if (logger != null && logger.isLoggable(level)) {
  6. String result = I18nUtil.localizeMessage(bundleName, msgKey, params,
  7. getExtensionClassLoader());
  8. logger.log(getClass().getName(), level, result, null);
  9. }
  10. }
  11. }

代码示例来源:origin: org.apache.uima/uimafit-core

  1. public void logrb(Level level, String sourceClass, String sourceMethod, String bundleName,
  2. String msgKey, Object param1) {
  3. if (context != null) {
  4. Logger logger = context.getLogger();
  5. if (logger != null && logger.isLoggable(level)) {
  6. String result = I18nUtil.localizeMessage(bundleName, msgKey, new Object[] { param1 },
  7. getExtensionClassLoader());
  8. logger.log(getClass().getName(), level, result, null);
  9. }
  10. }
  11. }

相关文章