Java源码示例:org.apache.uima.util.Level

示例1
/**
 * Dumps all events in the process trace object.
 *
 * @param aPTr -
 *          event container
 */
public static void dumpEvents(ProcessTrace aPTr) {
  List aList = aPTr.getEvents();
  for (int i = 0; i < aList.size(); i++) {
    ProcessTraceEvent prEvent = (ProcessTraceEvent) aList.get(i);
    String aEvType = prEvent.getType();
    if (System.getProperty("DEBUG_EVENTS") != null) {
      if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
        UIMAFramework.getLogger(CPMUtils.class).log(
                Level.FINEST,
                "Returning Report With Event::" + aEvType + " For Component:::"
                        + prEvent.getComponentName() + " Duration:::"
                        + prEvent.getDurationExcludingSubEvents());
      }
    }
  }

}
 
示例2
/**
 * @see AnalysisEngine#processAndOutputNewCASes(CAS)
 */
public CasIterator processAndOutputNewCASes(CAS aCAS) throws AnalysisEngineProcessException {
  // logging and instrumentation
  String resourceName = getMetaData().getName();
  Logger logger = getLogger();
  logger.logrb(Level.FINE, CLASS_NAME.getName(), "process", LOG_RESOURCE_BUNDLE,
          "UIMA_analysis_engine_process_begin__FINE", resourceName);
  try {
    CasIterator iterator = _getASB().process(aCAS);

    // log end of event
    logger.logrb(Level.FINE, CLASS_NAME.getName(), "process", LOG_RESOURCE_BUNDLE,
            "UIMA_analysis_engine_process_end__FINE", resourceName);
    return iterator;
  } catch (Exception e) {
    // log and rethrow exception
    logger.log(Level.SEVERE, "", e);
    if (e instanceof AnalysisEngineProcessException)
      throw (AnalysisEngineProcessException) e;
    else
      throw new AnalysisEngineProcessException(e);
  }
}
 
示例3
/**
 * Prints the stats.
 *
 * @param prT the pr T
 */
public static void printStats(ProcessTrace prT) {
  if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
    UIMAFramework.getLogger(Checkpoint.class).log(Level.FINEST,
            "\n\t\t\t----------------------------------------");
    UIMAFramework.getLogger(Checkpoint.class).log(Level.FINEST, "\t\t\t\t PERFORMANCE REPORT ");
    UIMAFramework.getLogger(Checkpoint.class).log(Level.FINEST,
            "\t\t\t----------------------------------------\n");
  }
  // get the list of events from the processTrace
  List eveList = prT.getEvents();
  printEveList(eveList, 0);
  if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
    UIMAFramework.getLogger(Checkpoint.class).log(Level.FINEST,
            "_________________________________________________________________\n");
  }
}
 
示例4
private void logJTafException(UimacppException e) {
  if (e.getEmbeddedException() instanceof InternalTafException) {
    InternalTafException tafExc = (InternalTafException) e.getEmbeddedException();
    long errorCode = tafExc.getTafErrorCode();
    String errorName = "";
    try {
      errorName = UimacppEngine.getErrorMessage(errorCode);
    } catch (UimacppException jtafexc) {
      log.logrb(Level.SEVERE, CLASS_NAME.getName(), "logJTafException", LOG_RESOURCE_BUNDLE,
              "UIMA_error_while_getting_name__SEVERE", jtafexc.getMessage());
      errorName = "";
    }

    log.logrb(Level.SEVERE, CLASS_NAME.getName(), "logJTafException", LOG_RESOURCE_BUNDLE,
            "UIMA_taf_internal_exception__SEVERE",
            new Object[] {errorCode, errorName });
  }
  Exception et = e.getEmbeddedException();

  // log exception
  log.log(Level.SEVERE, et.getMessage(), et);
}
 
示例5
public void testLogWrapperCreation() throws Exception {
  
  // Set the root logger's level to INFO ... may not be the default
  java.util.logging.Logger.getLogger("").setLevel(java.util.logging.Level.INFO);

  try {
  org.apache.uima.util.Logger uimaLogger = JSR47Logger_impl.getInstance();
  org.apache.uima.util.Logger classLogger = JSR47Logger_impl.getInstance(this.getClass());
  uimaLogger.setLevel(null);  // causes it to inherit from above
  classLogger.setLevel(null);  // causes it to inherit from above

  // check base configuration
  Assert.assertNotNull(uimaLogger);
  Assert.assertNotNull(classLogger);
  Assert.assertTrue(uimaLogger.isLoggable(Level.INFO));
  Assert.assertTrue(classLogger.isLoggable(Level.INFO));
  } finally {
    java.util.logging.Logger.getLogger("").setLevel(java.util.logging.Level.INFO);

  }
}
 
示例6
/**
 * Retrieves the dictionary files as configured in the preprocessing configuration.
 *
 * @param list
 *            the list
 * @return the dictionary files
 */
private List<File> getDictionaryFiles(String list) {
	List<File> files = new ArrayList<File>();
	for (String f : list.split(", +?")) {
		String[] args = f.split(":");
		if (args.length > 2) {
			logger.log(Level.SEVERE,
					"Could not parse dictionary files configuration: '" + list + "'\n"
							+ "Expecting format 'dictionaryfiles = langcode:filename1, langcode:filename2, ...'.\n"
							+ "You can also omit 'langcode:' to apply dictionary to all languages.");
			System.exit(1);
		}
		if (args.length == 1 || (args.length == 2 && args[0].equals(languageCode))) {
			String fname = args.length == 1 ? args[0] : args[1];
			files.add(new File(dictionaryDir, fname));
			logger.log(Level.INFO, "Applying dictionary file " + f + " to language " + languageCode);
		}
	}
	return files;
}
 
示例7
public static void dumpFeatures(CasData aCAS) {
  Iterator<FeatureStructure> it = aCAS.getFeatureStructures();
  while (it.hasNext()) {
      FeatureStructure fs = it.next();
      UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINE, CLASS_NAME.getName(), "dumpFeatures",
              LOG_RESOURCE_BUNDLE, "UIMA_cas_feature_structure_type__FINE", fs.getType());

      String[] names = fs.getFeatureNames();
      for (int i = 0; names != null && i < names.length; i++) {
        FeatureValue fValue = fs.getFeatureValue(names[i]);
        if (fValue != null) {
          UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINE, CLASS_NAME.getName(),
                  "dumpFeatures", LOG_RESOURCE_BUNDLE, "UIMA_cas_feature_name__FINE",
                  new Object[] { names[i], fValue.toString() });
        }
      }
  }

}
 
示例8
public void setLevel(Level level) {    
     if (level == Level.CONFIG) {
       // next seems to do nothing...
//       coreLogger.getContext().getConfiguration().getLoggerConfig(coreLogger.getName()).addFilter(FILTER_CONFIG);
       // next also seems to do nothing...
//       ((LoggerContext)LogManager.getContext(false)).getConfiguration().getLoggerConfig(coreLogger.getName()).addFilter(FILTER_CONFIG);
       coreLogger.get().addFilter(FILTER_CONFIG);
     } else {
//       coreLogger.getContext().getConfiguration().getLoggerConfig(coreLogger.getName()).removeFilter(FILTER_CONFIG);
       coreLogger.get().removeFilter(FILTER_CONFIG);
     }
     
     if (level == Level.FINEST) {
       coreLogger.get().addFilter(FILTER_FINEST);
     } else {
       coreLogger.get().removeFilter(FILTER_FINEST);
     }
          
     coreLogger.get().setLevel(getLog4jLevel(level));
     coreLogger.getContext().updateLoggers();
   }
 
示例9
/**
 * Parses filter expression.
 *
 * @param expression -
 *          filter expression to parse
 * @return - list of filters
 * @throws ParseException -
 */
public LinkedList parse(String expression) throws ParseException {
  StringTokenizer tokenizer = new StringTokenizer(expression, " !=", true);
  parseTokens(tokenizer);
  StringBuffer sb = new StringBuffer();
  for (int i = 0; i < expressionList.size(); i++) {
    Expression ex = (Expression) expressionList.get(i);
    if (ex.hasLeftPart()) {
      sb.append(ex.getLeftPart().get() + " ");
    }
    if (ex.hasOperand()) {
      sb.append(ex.getOperand().getOperand() + " ");
    }
    if (ex.hasRightPart()) {
      sb.append(ex.getRightPart().get() + " ");
    }
    if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
      UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
              "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_expression__FINEST",
              new Object[] { Thread.currentThread().getName(), sb.toString() });

    }
    sb.setLength(0);
  }
  return expressionList;
}
 
示例10
/**
   * @see JCasAnnotator_ImplBase#process(JCas)
   */
  public void process(JCas aJCas) throws AnalysisEngineProcessException {
    // get document text
    String docText = aJCas.getDocumentText();

    // loop over patterns
    for (int i = 0; i < mPatterns.length; i++) {
      Matcher matcher = mPatterns[i].matcher(docText);
      while (matcher.find()) {
        // found one - create annotation
        RoomNumber annotation = new RoomNumber(aJCas, matcher.start(), matcher.end());
        annotation.addToIndexes();
        annotation.setBuilding(mLocations[i]);
        getLogger().log(Level.FINEST, "Found: " + annotation);
        // or, using slf4j
        // note: this call skips constructing the message if tracing is not enabled
//        getSlf4jLogger().trace("Found: {}", annotation);
      }
    }
  }
 
示例11
/**
 * Get the logging level of the logger for TAFAnnotator. TAF only supports three levels of
 * logging. All logging levels INFO and below are mapped to the TAF message level.
 * @return the logging level
 */
public static int getLoggingLevel() {

  Logger uimacppLogger = UIMAFramework.getLogger(UimacppAnalysisComponent.class);

  if (uimacppLogger.isLoggable(Level.FINEST) || uimacppLogger.isLoggable(Level.FINER)
          || uimacppLogger.isLoggable(Level.FINE) || uimacppLogger.isLoggable(Level.CONFIG)
          || uimacppLogger.isLoggable(Level.INFO)) {
    return TAF_LOGLEVEL_MESSAGE;
  } else if (uimacppLogger.isLoggable(Level.WARNING)) {
    return TAF_LOGLEVEL_WARNING;
  } else if (uimacppLogger.isLoggable(Level.SEVERE)) {
    return TAF_LOGLEVEL_ERROR;
  } else {
    return TAF_LOGLEVEL_OFF;
  }
}
 
示例12
public static DocumentBuilderFactory createDocumentBuilderFactory() { 
  DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
  try {
    if ( ! IS_XML_ENABLE_DOCTYPE_DECL) {  // https://issues.apache.org/jira/browse/UIMA-6064
      documentBuilderFactory.setFeature(DISALLOW_DOCTYPE_DECL, true);
    }
  } catch (ParserConfigurationException e1) {
    UIMAFramework.getLogger().log(Level.WARNING, 
        "DocumentBuilderFactory didn't recognize setting feature " + DISALLOW_DOCTYPE_DECL);
  }
  
  try {
    documentBuilderFactory.setFeature(LOAD_EXTERNAL_DTD, false);
  } catch (ParserConfigurationException e) {
    UIMAFramework.getLogger().log(Level.WARNING, 
        "DocumentBuilderFactory doesn't support feature " + LOAD_EXTERNAL_DTD);
  }
  
  documentBuilderFactory.setXIncludeAware(false);
  documentBuilderFactory.setExpandEntityReferences(false);
  
  return documentBuilderFactory;
}
 
示例13
/**
 * Metadata is supposed to be presented in a four-tuple CSV format (docid, key,
 * value, type). @see uhh_lt.newsleak.reader.NewsleakReader should write a
 * temporary metadata file in that format (or assume it was produced by an
 * external process)
 * 
 * The CSV file is imported via postgres directly.
 * 
 * See <i>data/metadata_example.csv</i> for an example.
 */
private void metadataToPostgres() {

	try {
		// we need a mapping of document ids since ElasticsearchDocumentWriter generates
		// new Ids from an autoincrement-value
		String mappedMetadataFilepath = this.dataDirectory + File.separator + this.metadataFile + ".mapped";
		mappingIdsInMetadata(mappedMetadataFilepath);

		// import csv into postgres db
		CopyManager cpManager = new CopyManager((BaseConnection) conn);
		st.executeUpdate("TRUNCATE TABLE metadata;");
		this.logger.log(Level.INFO, "Importing metadata from " + mappedMetadataFilepath);
		Long n = cpManager.copyIn("COPY metadata FROM STDIN WITH CSV", new FileReader(mappedMetadataFilepath));
		this.logger.log(Level.INFO, n + " metadata imported");
	} catch (Exception e) {
		e.printStackTrace();
		System.exit(1);
	}
}
 
示例14
public boolean isReadOnly() {
  if (resourceMetadata == null) {
    try {
      resourceMetadata = textAnalysisProxy.getAnalysisEngineMetaData();
    } catch (ResourceServiceException e) {
      //can't throw exception from here so just log it and return the default
      UIMAFramework.getLogger(this.getClass()).log(Level.SEVERE, e.getMessage(), e);
      return false; 
    }
  }
  OperationalProperties opProps =  resourceMetadata.getOperationalProperties();
  if (opProps != null) {
    return !opProps.getModifiesCas();
  }
  return false; //default  
}
 
示例15
public boolean isLoggable(Level level, Marker marker) {
  switch (level.toInteger()) {
  case org.apache.uima.util.Level.OFF_INT:
    return false;
  case org.apache.uima.util.Level.SEVERE_INT:
    return logger.isErrorEnabled(marker);
  case org.apache.uima.util.Level.WARNING_INT:
    return logger.isWarnEnabled(marker);
  case org.apache.uima.util.Level.INFO_INT:
    return logger.isInfoEnabled(marker);
  case org.apache.uima.util.Level.CONFIG_INT:
    return logger.isInfoEnabled(marker);
  case org.apache.uima.util.Level.FINE_INT:
    return logger.isDebugEnabled(marker);
  case org.apache.uima.util.Level.FINER_INT:
    return logger.isTraceEnabled(marker);
  case org.apache.uima.util.Level.FINEST_INT:
    return logger.isTraceEnabled(marker);
  default: // for Level.ALL return false, that's what jul logger does
    return false;
  }
}
 
示例16
@Override
public void log(Level level, String msg) {
	switch (level.toInteger()) {
	case org.apache.uima.util.Level.OFF_INT:
		return;
	case org.apache.uima.util.Level.SEVERE_INT:
		this.slf4jLogger.error(msg);
	case org.apache.uima.util.Level.WARNING_INT:
		this.slf4jLogger.warn(msg);
	case org.apache.uima.util.Level.INFO_INT:
		this.slf4jLogger.info(msg);
	case org.apache.uima.util.Level.CONFIG_INT:
		this.slf4jLogger.debug(msg);
	case org.apache.uima.util.Level.FINE_INT:
		this.slf4jLogger.debug(msg);
	case org.apache.uima.util.Level.FINER_INT:
		this.slf4jLogger.trace(msg);
	case org.apache.uima.util.Level.FINEST_INT:
		this.slf4jLogger.trace(msg);
	default: // for all other cases return Level.ALL
		this.slf4jLogger.trace(msg);
	}
}
 
示例17
/**
   * Releases given cases back to pool.
   * 
   * @param aCASList -
   *          cas list to release
   */
  public void releaseCASes(CAS[] aCASList) {
    for (int i = 0; i < aCASList.length; i++) {
      if (aCASList[i] != null) {
        // aCASList[i].reset();
        casPool.releaseCas(aCASList[i]);
//        synchronized (casPool) {  // redundant - the above releaseCas call does this
//          casPool.notifyAll();
//        }

      } else {
        if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
          UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
                  "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_release_tcas__FINEST",
                  new Object[] { Thread.currentThread().getName() });
        }
      }
    }
  }
 
示例18
@Override
public void log(Level level, String msg, Object[] params) {
	switch (level.toInteger()) {
	case org.apache.uima.util.Level.OFF_INT:
		return;
	case org.apache.uima.util.Level.SEVERE_INT:
		this.slf4jLogger.error(msg, params);
	case org.apache.uima.util.Level.WARNING_INT:
		this.slf4jLogger.warn(msg, params);
	case org.apache.uima.util.Level.INFO_INT:
		this.slf4jLogger.info(msg, params);
	case org.apache.uima.util.Level.CONFIG_INT:
		this.slf4jLogger.debug(msg, params);
	case org.apache.uima.util.Level.FINE_INT:
		this.slf4jLogger.debug(msg, params);
	case org.apache.uima.util.Level.FINER_INT:
		this.slf4jLogger.trace(msg, params);
	case org.apache.uima.util.Level.FINEST_INT:
		this.slf4jLogger.trace(msg, params);
	default: // for all other cases return Level.ALL
		this.slf4jLogger.trace(msg, params);
	}
}
 
示例19
@Override
public void log(Level level, String msg, Throwable throwable) {
	switch (level.toInteger()) {
	case org.apache.uima.util.Level.OFF_INT:
		return;
	case org.apache.uima.util.Level.SEVERE_INT:
		this.slf4jLogger.error(msg, throwable);
	case org.apache.uima.util.Level.WARNING_INT:
		this.slf4jLogger.warn(msg, throwable);
	case org.apache.uima.util.Level.INFO_INT:
		this.slf4jLogger.info(msg, throwable);
	case org.apache.uima.util.Level.CONFIG_INT:
		this.slf4jLogger.debug(msg, throwable);
	case org.apache.uima.util.Level.FINE_INT:
		this.slf4jLogger.debug(msg, throwable);
	case org.apache.uima.util.Level.FINER_INT:
		this.slf4jLogger.trace(msg, throwable);
	case org.apache.uima.util.Level.FINEST_INT:
		this.slf4jLogger.trace(msg, throwable);
	default: // for all other cases return Level.ALL
		this.slf4jLogger.trace(msg, throwable);
	}
}
 
示例20
/**
 * log4j level mapping to UIMA level mapping. <br>
 * SEVERE (highest value) -&gt; SEVERE <br> 
 * WARNING -&gt; WARNING <br> 
 * INFO -&gt; INFO <br> 
 * CONFIG -&gt; INFO <br> 
 * FINE -&gt; DEBUG <br> 
 * FINER -&gt; TRACE <br> 
 * FINEST (lowest value) -&gt; TRACE <br> 
 * OFF -&gt; OFF <br> 
 * ALL -&gt; ALL <br>
 * 
 * @param level uima level
 * @return Level - corresponding log4j 2 level
 */
static org.apache.logging.log4j.Level getLog4jLevel(Level level) {
   switch (level.toInteger()) {
   case org.apache.uima.util.Level.OFF_INT:
      return org.apache.logging.log4j.Level.OFF;
   case org.apache.uima.util.Level.SEVERE_INT:
      return org.apache.logging.log4j.Level.ERROR;
   case org.apache.uima.util.Level.WARNING_INT:
      return org.apache.logging.log4j.Level.WARN;
   case org.apache.uima.util.Level.INFO_INT:
      return org.apache.logging.log4j.Level.INFO;
   case org.apache.uima.util.Level.CONFIG_INT:
      return org.apache.logging.log4j.Level.INFO;
   case org.apache.uima.util.Level.FINE_INT:
      return org.apache.logging.log4j.Level.DEBUG;
   case org.apache.uima.util.Level.FINER_INT:
     return org.apache.logging.log4j.Level.TRACE;
   case org.apache.uima.util.Level.FINEST_INT:
     return org.apache.logging.log4j.Level.TRACE;
   default: // for all other cases return Level.ALL
      return org.apache.logging.log4j.Level.ALL;
   }
}
 
示例21
/**
 * This method gets called when the CPM completes processing the collection. Depending on the type
 * of deployment this routine may issue a shutdown command to the service.
 * 
 * @see org.apache.uima.collection.base_cpm.CasProcessor#collectionProcessComplete(org.apache.uima.util.ProcessTrace)
 */
public void collectionProcessComplete(ProcessTrace aTrace) throws ResourceProcessException,
        IOException {
  if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
    UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
            "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_stopping_cp__FINEST",
            new Object[] { Thread.currentThread().getName(), name });
  }
  // Send shutdown command to Local services, meaning services started by the CPM on the same
  // machine in a different JVM. Remote services will not be shutdown since these may be started
  // for
  // use by different clients not necessarily just by the CPM
  if (textAnalysisProxy != null) {
    if ("local".equals(casProcessorType.getDeployment().toLowerCase())) {
      // true = send shutdown to remote service
      textAnalysisProxy.shutdown(true, doSendNotification());
    } else {
      // false = dont send shutdown to remote service, just close the client
      textAnalysisProxy.shutdown(false, doSendNotification());
    }
  }
  textAnalysisProxy = null;
  metadata = null;
}
 
示例22
/**
 * @see org.apache.uima.util.Logger#setOutputStream(java.io.PrintStream)
 * 
 * @deprecated use external configuration possibility
 */
@Override
@Deprecated
public void setOutputStream(PrintStream out) {
  // if PrintStream is null set root logger level to OFF
  if (out == null) {
    LogManager.getLogManager().getLogger("").setLevel(java.util.logging.Level.OFF);
    return;
  }

  // get root logger handlers - root logger is parent of all loggers
  Handler[] handlers = LogManager.getLogManager().getLogger("").getHandlers();

  // remove all current handlers
  for (int i = 0; i < handlers.length; i++) {
    LogManager.getLogManager().getLogger("").removeHandler(handlers[i]);
  }

  // add new UIMAStreamHandler with the given output stream
  UIMAStreamHandler streamHandler = new UIMAStreamHandler(out, new UIMALogFormatter());
  streamHandler.setLevel(java.util.logging.Level.ALL);
  LogManager.getLogManager().getLogger("").addHandler(streamHandler);
}
 
示例23
/**
 * @param marker
 *          the marker data specific to this log statement
 * @param msgSupplier
 *          A function, which when called, produces the desired log message
 */
@Override
public void trace(Marker marker, Supplier<String> msgSupplier, Throwable throwable) {
  if (isLoggable(Level.TRACE, marker) && isNotLimited(Level.TRACE)) {
    log2(marker, fqcnCmn, Level.TRACE, msgSupplier.get(), null, throwable);
  }
}
 
示例24
private JCas setMetadata( final JCas jCas ) throws SQLException {
	final Metadata metadata = new Metadata( jCas );
	final SourceData sourcedata = new SourceData( jCas );
	metadata.setPatientID( 0L );
	sourcedata.setAuthorSpecialty( "Unknown" );
	sourcedata.setNoteTypeCode( "UnknownNoteType" );
	sourcedata.setSourceEncounterId( -1L+"" );
	sourcedata.setSourceInstanceId( -1L+"" );
	sourcedata.setSourceOriginalDate( (new Timestamp(System.currentTimeMillis())).toString() );
	metadata.setSourceData( sourcedata );
	jCas.addFsToIndexes( metadata );
	logger.log(Level.INFO, metadata.getPatientID() + " " + sourcedata.getSourceEncounterId() + " " + sourcedata.getSourceInstanceId());
	return jCas;
}
 
示例25
/**
 * Called when the initialization is completed.
 * 
 * @see org.apache.uima.collection.processing.StatusCallbackListener#initializationComplete()
 */
public void initializationComplete() {
  if (UIMAFramework.getLogger().isLoggable(Level.CONFIG)) {
    UIMAFramework.getLogger(this.getClass()).logrb(Level.CONFIG, this.getClass().getName(),
            "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_cpm_init_complete__CONFIG",
            new Object[] { Thread.currentThread().getName() });
  }
}
 
示例26
/**
 * Analyzes a given document by a AnalysisEngine. When completed this method returns a VinciFrame
 * containing XCAS translated into a set of Vinci subFrames. Each subframe containing one
 * annotation with all its attributes.
 *
 * @param ct the ct
 * @return VinciFrame containing XCAS translated into a set of Vinci subframes.
 * @exception Exception              if there is an error during processing
 */
private Transportable analyze(CASTransportable ct) throws Exception {
  CAS cas = ct.getCas();
  try {
    long annotStartTime = System.currentTimeMillis();
    mAE.process(cas);
    int annotationTime = (int) (System.currentTimeMillis() - annotStartTime);
    if (debug) {
      System.out.println("Annotation took: " + annotationTime + "ms");
    }
    ct.getExtraDataFrame().fset(Constants.ANNOTATION_TIME, annotationTime);
    // Extract CAS
    // UIMAFramework.getLogger().log("CAS ACount::" +
    // cas.getAnnotationIndex().size());
    int totalAnnots = 0;
    SofaFS sofa;
    FSIterator sItr = cas.getSofaIterator();
    while (sItr.isValid()) {
      sofa = (SofaFS) sItr.get();
      totalAnnots += cas.getView(sofa).getAnnotationIndex().size();
      sItr.moveToNext();
    }
    UIMAFramework.getLogger().log(Level.FINEST, "CAS ACount::" + totalAnnots);
    ct.setCommand(null);
    return ct;
  } catch (Exception ex) {
    ct.cleanup();
    throw ex;
  }
}
 
示例27
/**
 * Pauses this thread.
 */
public void pauseIt() {
  if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
    UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
            "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_pause_cpe__FINEST",
            new Object[] { Thread.currentThread().getName() });
  }
  synchronized (lockForPause) {
    pause = true;
  }
}
 
示例28
/**
 * Remove unlikely annotation.
 *
 * @param annotations
 *            removal candidates
 */
private void cleanAnnotation(Collection<? extends Annotation> annotations) {
	for (Annotation a : annotations) {
		// less than two letters
		String ne = a.getCoveredText();
		if (ne.replaceAll("[^\\p{L}]", "").length() < 2) {
			log.log(Level.FINEST, "Removing Named Entity: " + ne);
			a.removeFromIndexes();
		}
	}
}
 
示例29
/**
 * Gets the UIMA reader according to the current configuration.
 *
 * @param type
 *            The reader type (e.g. "csv" for externally preprocessed fulltexts
 *            and metadata, or "hoover" for the Hoover text extraction system)
 * @return the reader
 * @throws ResourceInitializationException
 *             the resource initialization exception
 */
public CollectionReaderDescription getReader(String type) throws ResourceInitializationException {
	CollectionReaderDescription reader = null;
	if (type.equals("csv")) {
		reader = CollectionReaderFactory.createReaderDescription(NewsleakCsvStreamReader.class, this.typeSystem,
				NewsleakCsvStreamReader.PARAM_DOCUMENT_FILE, this.documentFile,
				NewsleakCsvStreamReader.PARAM_METADATA_FILE, this.metadataFile,
				NewsleakCsvStreamReader.PARAM_INPUTDIR, this.dataDirectory,
				NewsleakCsvStreamReader.PARAM_DEFAULT_LANG, this.defaultLanguage,
				NewsleakReader.PARAM_DEBUG_MAX_DOCS, this.debugMaxDocuments, NewsleakReader.PARAM_MAX_DOC_LENGTH,
				this.maxDocumentLength);
	} else if (type.equals("hoover")) {
		this.metadataFile = this.hooverTmpMetadata;
		ExternalResourceDescription hooverResource = ExternalResourceFactory.createExternalResourceDescription(
				HooverResource.class, HooverResource.PARAM_HOST, this.hooverHost, HooverResource.PARAM_CLUSTERNAME,
				this.hooverClustername, HooverResource.PARAM_INDEX, this.hooverIndex, HooverResource.PARAM_PORT,
				this.hooverPort, HooverResource.PARAM_SEARCHURL, this.hooverSearchUrl);
		reader = CollectionReaderFactory.createReaderDescription(HooverElasticsearchReader.class, this.typeSystem,
				HooverElasticsearchReader.RESOURCE_HOOVER, hooverResource,
				HooverElasticsearchReader.RESOURCE_METADATA, this.getMetadataResourceDescription(),
				NewsleakReader.PARAM_DEBUG_MAX_DOCS, this.debugMaxDocuments, NewsleakReader.PARAM_MAX_DOC_LENGTH,
				this.maxDocumentLength);
	} else {
		this.logger.log(Level.SEVERE, "Unknown reader type: " + type);
		System.exit(1);
	}
	return reader;
}
 
示例30
public void setElasticsearchDefaultAnalyzer(String isoCode) {

		// language analyzers supported by elasticsearch 2.4
		HashMap<String, String> analyzers = new HashMap<String, String>();
		analyzers.put("ara", "arabic");
		analyzers.put("bul", "bulgarian");
		analyzers.put("cat", "catalan");
		analyzers.put("ces", "czech");
		analyzers.put("dan", "danish");
		analyzers.put("eng", "english");
		analyzers.put("nld", "dutch");
		analyzers.put("fin", "finnish");
		analyzers.put("fra", "french");
		analyzers.put("deu", "german");
		analyzers.put("ell", "greek");
		analyzers.put("hin", "hindi");
		analyzers.put("hun", "hungarian");
		analyzers.put("ind", "indonesian");
		analyzers.put("ita", "italian");
		analyzers.put("lav", "latvian");
		analyzers.put("lit", "lithuanian");
		analyzers.put("nno", "norwegian");
		analyzers.put("fas", "persian");
		analyzers.put("por", "portuguese");
		analyzers.put("ron", "romanian");
		analyzers.put("rus", "russian");
		analyzers.put("spa", "spanish");
		analyzers.put("swe", "swedish");
		analyzers.put("tur", "turkish");
		analyzers.put("tha", "thai");

		// set elasticsearch analyse (english as default)
		this.elasticsearchDefaultAnalyzer = analyzers.containsKey(isoCode) ? analyzers.get(isoCode) : "english";

		if (!analyzers.containsKey(isoCode)) {
			this.logger.log(Level.WARNING, "Configuration parameter defaultlanguage=" + isoCode
					+ " is not supported by elasticsearch language analyzers. Switching to 'english' as default elasticsearch analyzer.");
		}

	}