org.apache.uima.util.Logger类的使用及代码示例

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

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

Logger介绍

[英]A Logger is a component used to log messages. This interface defines the standard way for UIMA components to produce log output.

In the UIMA SDK, this interface is implemented using the Java 1.4 logger as a back end. If you want to configure the logger, for example to specify the location of the log file and the logging level, you should use the standard Java 1.4 logger properties or the java.util.logging APIs. See the section "Specifying the Logging Configuration" in the Annotator and Analysis Engine Developer's Guide chapter of the UIMA documentation for more information.
[中]Logger是用于记录消息的组件。此接口定义UIMA组件生成日志输出的标准方式。
在UIMA SDK中,此接口是使用Java 1.4记录器作为后端实现的。如果要配置记录器,例如指定日志文件的位置和日志级别,则应使用标准Java 1.4记录器属性或Java。util。日志API。有关更多信息,请参阅UIMA文档的注释器和分析引擎开发人员指南一章中的“指定日志记录配置”一节。

代码示例

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

protected void process(CAS cas, AnnotationFS sentenceAnnotation) {
 FSIndex<AnnotationFS> allTokens = cas.getAnnotationIndex(mTokenType);
 ContainingConstraint containingConstraint =
   new ContainingConstraint(sentenceAnnotation);
 String sentence = sentenceAnnotation.getCoveredText();
 Iterator<AnnotationFS> containingTokens = cas.createFilteredIterator(
   allTokens.iterator(), containingConstraint);
 List<Span> tokenSpans = new LinkedList<>();
 while (containingTokens.hasNext()) {
  AnnotationFS token = containingTokens.next();
  tokenSpans.add(new Span(token.getBegin() - sentenceAnnotation.getBegin(),
    token.getEnd() - sentenceAnnotation.getBegin()));
 }
 ParseConverter converter = new ParseConverter(sentence, tokenSpans.toArray(new Span[tokenSpans.size()]));
 Parse unparsedTree = converter.getParseForTagger();
 if (unparsedTree.getChildCount() > 0) {
  Parse parse = mParser.parse(unparsedTree);
  // TODO: We need a strategy to handle the case that a full
  //       parse could not be found. What to do in this case?
  parse = converter.transformParseFromTagger(parse);
  if (mLogger.isLoggable(Level.INFO)) {
   StringBuffer parseString = new StringBuffer();
   parse.show(parseString);
   mLogger.log(Level.INFO, parseString.toString());
  }
  createAnnotation(cas, sentenceAnnotation.getBegin(), parse);
 }
}

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

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;
}

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

@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;
 }
}

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

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);
}

代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.opennlp-asl

@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);
  }
};

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

public void removeMessageOrigin(String aCasReferenceId) {
  if (originMap.containsKey(aCasReferenceId)) {
   originMap.remove(aCasReferenceId);
   if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.FINEST)) {
    UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINEST, CLASS_NAME.getName(),
        "removeMessageOrigin", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
        "UIMAEE_remove_msg_origin_entry__FINEST",
        new Object[] { getComponentName(), aCasReferenceId });
   }
  }
}

代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.opennlp-asl

@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);
      }
    };

代码示例来源:origin: org.apache.uima/uimaj-cpe

/**
 * Disable a CASProcessor in the processing pipeline.
 *
 * @param aCasProcessorName          CASProcessor to be added to the processing pipeline
 */
public void enableCasProcessor(String aCasProcessorName) {
 for (int i = 0; i < annotatorList.size(); i++) {
  ProcessingContainer pc = ((ProcessingContainer) annotatorList.get(i));
  if (pc.getName().equals(aCasProcessorName)) {
   if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
    UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
        "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_enabled_cp__FINEST",
        new Object[] { Thread.currentThread().getName(), aCasProcessorName });
   }
   pc.setStatus(Constants.CAS_PROCESSOR_RUNNING);
  }
 }
}

代码示例来源:origin: org.apache.uima/uimaj-cpe

public synchronized void addCasProcessor(CasProcessor aCasProcessor) {
 if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
  UIMAFramework.getLogger(this.getClass()).logrb(
      Level.FINEST,
      this.getClass().getName(),
      "process",
      CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
      "UIMA_CPM_add_cp_to_pool__FINEST",
      new Object[] { Thread.currentThread().getName(),
        aCasProcessor.getProcessingResourceMetaData().getName() });
 }
 mAllInstances.add(aCasProcessor);
 mFreeInstances.add(aCasProcessor);
 if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
  UIMAFramework.getLogger(this.getClass()).logrb(
      Level.FINEST,
      this.getClass().getName(),
      "process",
      CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
      "UIMA_CPM_show_cp_pool_size__FINEST",
      new Object[] { Thread.currentThread().getName(),
        String.valueOf(mAllInstances.size()), String.valueOf(mFreeInstances.size()) });
 }
}

代码示例来源:origin: org.apache.uima/uimaj-cpe

UIMAFramework.getLogger(this.getClass()).log(Level.CONFIG, " Adding New Annotator:" + aCpName);
if (analysisEngines.containsKey(aCpName)) {
 if (UIMAFramework.getLogger().isLoggable(Level.CONFIG)) {
  UIMAFramework.getLogger(this.getClass()).logrb(Level.CONFIG, this.getClass().getName(),
      "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
      "UIMA_CPM_add_pcp_to_existing_list__CONFIG",
 ((List) annotatorDeployList.get(listIndex)).add(aProcessor);
} else {
 ArrayList newList = new ArrayList();
 newList.add(0, aProcessor);
 analysisEngines.put(aCpName, newList);
 annotatorDeployList.add(0, newList);
 if (UIMAFramework.getLogger().isLoggable(Level.CONFIG)) {
  UIMAFramework.getLogger(this.getClass()).logrb(Level.CONFIG, this.getClass().getName(),
      "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
      "UIMA_CPM_add_pcp_to_new_list__CONFIG",

代码示例来源:origin: org.apache.uima/uimaj-cpe

if (!mFreeInstances.isEmpty()) {
 if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
  UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
      "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
      "UIMA_CPM_checking_out_cp_from_pool__FINEST",
      new Object[] { Thread.currentThread().getName() });
 CasProcessor r = (CasProcessor) mFreeInstances.remove(0);
 if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
  UIMAFramework.getLogger(this.getClass()).logrb(
      Level.FINEST,
      this.getClass().getName(),
      "UIMA_CPM_show_cp_pool_size__FINEST",
      new Object[] { Thread.currentThread().getName(),
        String.valueOf(mAllInstances.size()), String.valueOf(mFreeInstances.size()) });
 if (UIMAFramework.getLogger().isLoggable(Level.WARNING)) {
  UIMAFramework.getLogger(this.getClass()).logrb(
      Level.WARNING,
      this.getClass().getName(),

代码示例来源:origin: org.apache.uima/uimaj-cpe

if (UIMAFramework.getLogger().isLoggable(Level.WARNING)) {
 UIMAFramework.getLogger(this.getClass()).logrb(Level.WARNING, this.getClass().getName(),
     "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_invalid_checkin__WARNING",
     new Object[] { Thread.currentThread().getName() });
aCas.reset();
int index = checkedOutInstances.indexOf(aCas); // new code JC 05/11/2005
if (index != -1) {
 checkedOutInstances.remove(index);
 if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
  UIMAFramework.getLogger(this.getClass()).logrb(
      Level.FINEST,
      this.getClass().getName(),
      "UIMA_CPM_removed_from_checkedout_list__FINEST",
      new Object[] { Thread.currentThread().getName(),
        String.valueOf(checkedOutInstances.size()) });
if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
 UIMAFramework.getLogger(this.getClass()).logrb(
     Level.FINEST,
     this.getClass().getName(),

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

public synchronized void saveTime(long aTime, String aCasReferenceId, String anEndpointName) {
 String key = aCasReferenceId + anEndpointName;
 if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.FINE)) {
  UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINE, CLASS_NAME.getName(), "saveTime",
      UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_save_time__FINE",
      new Object[] { aTime, aCasReferenceId, getComponentName(), anEndpointName, key });
 }
 statsMap.put(key, Long.valueOf(aTime));
}

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

protected void stopTransportLayer() {
 if (transports.size() > 0) {
  Set<Entry<String, UimaTransport>> set = transports.entrySet();
  for (Entry<String, UimaTransport> entry : set) {
   UimaTransport transport = entry.getValue();
   try {
    transport.stopIt();
   } catch (Exception e) {
    if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
     UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, CLASS_NAME.getName(),
         "stopTransportLayer", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
         "UIMAEE_service_exception_WARNING", getComponentName());
     UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, getClass().getName(),
         "stopTransportLayer", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
         "UIMAEE_exception__WARNING", e);
    }
   }
  }
 }
}

代码示例来源:origin: org.apache.uima/uimaj-cpe

Object anObject = queue.remove(aQueueIndex);
if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
 UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
     "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
     "UIMA_CPM_chunk_state_false_timeout__FINEST",

代码示例来源:origin: de.tudarmstadt.ukp.dkpro.tc/de.tudarmstadt.ukp.dkpro.tc.core-asl

@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();
  }
}

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

@Override
public void process(CAS cas) throws AnalysisEngineProcessException {
 FSIndex<AnnotationFS> sentences = cas.getAnnotationIndex(sentenceType);
     .createAnnotation(tokenType,
       sentenceOffset + tokenSpans[i].getStart(), sentenceOffset
         + tokenSpans[i].getEnd());
   cas.getIndexRepository().addFS(tokenAnnotations[i]);
   if (logger.isLoggable(Level.FINER)) {
    tokeninzedSentenceLog.append(tokenAnnotations[i].getCoveredText());
    tokeninzedSentenceLog.append(' ');
  if (logger.isLoggable(Level.FINER)) {
   logger.log(Level.FINER, "\"" + tokeninzedSentenceLog.toString() + "\"");

代码示例来源:origin: org.apache.uima/uimaj-cpe

if (anObject instanceof UimaTimer) {
  timer = (UimaTimer) anObject;
  if (UIMAFramework.getLogger().isLoggable(Level.CONFIG)) {
   UIMAFramework.getLogger(TimerFactory.class).logrb(Level.CONFIG,
       TimerFactory.class.getName(), "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
       "UIMA_CPM_show_timer_class__CONFIG",
 throw new ResourceInitializationException(ResourceInitializationException.CLASS_NOT_FOUND,
     new Object[] { aClassName, "CPE" }, e);
} catch (IllegalAccessException e) {
 throw new ResourceInitializationException(
     ResourceInitializationException.COULD_NOT_INSTANTIATE, new Object[] { aClassName,
       "CPE" }, e);
} catch (InstantiationException e) {
 throw new ResourceInitializationException(
     ResourceInitializationException.COULD_NOT_INSTANTIATE, new Object[] { aClassName,
       "CPE" }, e);
if (UIMAFramework.getLogger().isLoggable(Level.CONFIG)) {
 UIMAFramework.getLogger(TimerFactory.class).logrb(Level.CONFIG,
     TimerFactory.class.getName(), "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
     "UIMA_CPM_java_timer__CONFIG", new Object[] { Thread.currentThread().getName() });

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

throw new ResourceInitializationException(e1);
  UIMAFramework.getLogger().logrb(Level.CONFIG, ResourceManager_impl.class.getName(),
      "initializeExternalResources", LOG_RESOURCE_BUNDLE,
      "UIMA_overridden_resource__CONFIG",
      new Object[] { e.getKey(), aQualifiedContextName, definingContext });
 } else {
  UIMAFramework.getLogger().logrb(Level.WARNING, ResourceManager_impl.class.getName(),
      "initializeExternalResources", LOG_RESOURCE_BUNDLE,
      "UIMA_duplicate_resource_name__WARNING",
throw new ResourceInitializationException(e1);

代码示例来源:origin: fr.univ-nantes.julestar/uima-tokens-regex

@Override
public void load(DataResource aData) throws ResourceInitializationException {
  CharStream input;
  try {
    UIMAFramework.getLogger().log(Level.FINE, "Loading resource " + KEY_TOKEN_REGEX_RULES + " at: " + aData.getUri());
    
    input = CharStreams.fromStream(aData.getInputStream());
    UimaTokenRegexLexer lexer = new UimaTokenRegexLexer(input);
    CommonTokenStream tokens = new CommonTokenStream(lexer);
    UimaTokenRegexParser parser = new UimaTokenRegexParser(tokens);
    listener = new AutomataParserListener( parser );
    listener.setAllowMatchingEmptySequences(false);
    ParseTreeWalker.DEFAULT.walk(listener, parser.ruleList());
  } catch (IOException e) {
    throw new ResourceInitializationException(e);
  }
}

相关文章