本文整理汇总了Java中org.apache.uima.collection.EntityProcessStatus类的典型用法代码示例。如果您正苦于以下问题:Java EntityProcessStatus类的具体用法?Java EntityProcessStatus怎么用?Java EntityProcessStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EntityProcessStatus类属于org.apache.uima.collection包,在下文中一共展示了EntityProcessStatus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: entityProcessComplete
import org.apache.uima.collection.EntityProcessStatus; //导入依赖的package包/类
/**
* Called when the processing of a Document is completed. <br>
* The process status can be looked at and corresponding actions taken.
*
* @param aCas CAS corresponding to the completed processing
* @param aStatus EntityProcessStatus that holds the status of all the events
* for aEntity
*/
public void entityProcessComplete(CAS aCas, EntityProcessStatus aStatus) {
if (aStatus.isException()) {
String docURI = getDocumentURI(aCas);
docsWithException.add(docURI);
docsProcessedWithException++;
System.err.println(String.format("During the processing of %s", docURI));
List<Exception> exceptions = aStatus.getExceptions();
for (int i = 0; i < exceptions.size(); i++) {
((Throwable) exceptions.get(i)).printStackTrace();
}
return;
}
entityCount++;
String docText = aCas.getDocumentText();
if (docText != null) {
size += docText.length();
}
if (entityReportingInterval != 0 && entityCount % entityReportingInterval == 0) {
System.out.println(String.format("%s entities have been processed", entityCount));
}
}
示例2: entityProcessComplete
import org.apache.uima.collection.EntityProcessStatus; //导入依赖的package包/类
/**
* @param aCas the CAS containing the processed entity and the analysis results
* @param aStatus the status of the processing. This object contains a record of any Exception that occurred, as well as timing information.
* @see org.apache.uima.aae.client.UimaAsBaseCallbackListener#entityProcessComplete(org.apache.uima.cas.CAS, org.apache.uima.collection.EntityProcessStatus)
*/
@Override
public void entityProcessComplete(CAS aCas, EntityProcessStatus aStatus) {
try {
super.entityProcessComplete(aCas, aStatus);
// See if we need to validate the connection.
if (conn == null) {
validateConnection();
}
if (hasFilteredAnnotation(aCas) && hasAnnotationsToProcess(aCas))
batch.addAll(getRows(aCas));
// Batch full, process it!
if (batch.size() >= this.batchSize) {
processBatch();
}
} catch (Exception e) {
LOG.error("Error validating the connection or executing the batch", e);
//If exitOnError is set then kill the client to prevent doing damage to the database
if (exitOnError)
System.exit(1);
throw new RuntimeException(e);
}
}
示例3: entityProcessComplete
import org.apache.uima.collection.EntityProcessStatus; //导入依赖的package包/类
/**
* @param aCas the CAS containing the processed entity and the analysis results
* @param aStatus the status of the processing. This object contains a record of any Exception that occurred, as well as timing information.
* @see org.apache.uima.aae.client.UimaAsBaseCallbackListener#entityProcessComplete(org.apache.uima.cas.CAS, org.apache.uima.collection.EntityProcessStatus)
*/
@Override
public void entityProcessComplete(CAS aCas, EntityProcessStatus aStatus) {
LOG.debug("EntityProcessComplete event");
super.entityProcessComplete(aCas, aStatus);
numReceived++;
if (checkForError(aCas, aStatus) && exitOnError)
return;
try {
this.referenceID = getReferenceLocation(aCas.getJCas());
} catch (CASException e) {
this.referenceID = null;
this.docInfo = null;
LOG.error(e.getMessage(), e);
}// catch
}
示例4: collectionProcessComplete
import org.apache.uima.collection.EntityProcessStatus; //导入依赖的package包/类
/**
* @param aStatus the status of the processing. This object contains a record of any Exception that occurred, as well as timing information.
* @see org.apache.uima.aae.client.UimaAsBaseCallbackListener#collectionProcessComplete(org.apache.uima.collection.EntityProcessStatus)
*/
@Override
public void collectionProcessComplete(EntityProcessStatus aStatus) {
super.collectionProcessComplete(aStatus);
//Ensure all CAS have come back before continuing
int count = 0;
while (numSent != numReceived && count < 10) {
LOG.warn("Have not recieved all CAS's from the Service, sleeping for 2 seconds");
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
LOG.error(e.getMessage(), e);
}
count++;
}//while
if (numSent != numReceived)
LOG.warn("Did not recieve all CAS's back from the service.");
LOG.info("Collection Processing Stats: \n" + "Sent CAS Count: "
+ numSent + "\n" + "Received CAS Count: " + numReceived);
}
示例5: entityProcessComplete
import org.apache.uima.collection.EntityProcessStatus; //导入依赖的package包/类
/**
* Called with a completely processed CAS.
*
* @param aCas the returned cas.
* @param aStatus the status of the processing. This object contains a record of any Exception that occurred, as well as timing information.
*/
@Override
public void entityProcessComplete(CAS aCas, EntityProcessStatus aStatus) {
super.entityProcessComplete(aCas, aStatus);
if (writer == null)
writer = writerBuilder.buildCSVWriter();
if (hasFilteredAnnotation(aCas) && hasAnnotationsToProcess(aCas)) {
List<String[]> rows = getRows(aCas);
if (rows == null || rows.size() < 1)
return;
writer.writeAll(rows);
}
try {
writer.flush();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例6: entityProcessComplete
import org.apache.uima.collection.EntityProcessStatus; //导入依赖的package包/类
/**
* Called when the processing of a Document is completed. <br>
* The process status can be looked at and corresponding actions taken.
*
* @param aCas
* CAS corresponding to the completed processing
* @param aStatus
* EntityProcessStatus that holds the status of all the events for aEntity
*/
public void entityProcessComplete(CAS aCas, EntityProcessStatus aStatus) {
if (aStatus.isException()) {
List exceptions = aStatus.getExceptions();
for (int i = 0; i < exceptions.size(); i++) {
((Throwable) exceptions.get(i)).printStackTrace();
}
return;
}
entityCount++;
String docText = aCas.getDocumentText();
if (docText != null) {
size += docText.length();
}
}
示例7: collectionProcessComplete
import org.apache.uima.collection.EntityProcessStatus; //导入依赖的package包/类
/**
* Called when the collection processing is completed.
*
* @see org.apache.uima.collection.StatusCallbackListener#collectionProcessComplete()
*/
@Override
public void collectionProcessComplete(EntityProcessStatus aStatus) {
maybeStopAndCroak(aStatus, "Error on collection process complete call to remote service:");
log.info("Completed {} document(s.)", entityCount);
if (size > 0) {
log.info("Document(s) had {} characters.", size);
}
long elapsedTime = System.currentTimeMillis() - mStartTime;
log.info("Time elapsed: {}.", renderMillis(elapsedTime));
}
示例8: collectionProcessComplete
import org.apache.uima.collection.EntityProcessStatus; //导入依赖的package包/类
/**
* @see org.apache.uima.aae.client.UimaAsBaseCallbackListener#collectionProcessComplete(org.apache.uima.collection.EntityProcessStatus)
* @param aStatus the status of the processing. This object contains a record of any Exception that occurred, as well as timing information.
*/
@Override
public void collectionProcessComplete(EntityProcessStatus aStatus) {
super.collectionProcessComplete(aStatus);
if (launchAnnotationViewer) {
launchAnnotationViewer();
}
}
示例9: collectionProcessComplete
import org.apache.uima.collection.EntityProcessStatus; //导入依赖的package包/类
/**
* @param aStatus the status of the processing. This object contains a record of any Exception that occurred, as well as timing information.
* @see org.apache.uima.aae.client.UimaAsBaseCallbackListener#collectionProcessComplete(org.apache.uima.collection.EntityProcessStatus)
*/
@Override
public void collectionProcessComplete(EntityProcessStatus aStatus) {
try {
super.collectionProcessComplete(aStatus);
// Run any partial batch.
processBatch();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例10: initializationComplete
import org.apache.uima.collection.EntityProcessStatus; //导入依赖的package包/类
/**
* Called once client initialization is complete.
*
* @param aStatus the status of the processing.
* @see org.apache.uima.aae.client.UimaAsBaseCallbackListener#initializationComplete(org.apache.uima.collection.EntityProcessStatus)
*/
@Override
public void initializationComplete(EntityProcessStatus aStatus) {
if (aStatus != null && aStatus.isException()) {
LOG.error("Exceptions thrown on getMeta call to remote service...");
List<Exception> exceptions = aStatus.getExceptions();
for (Exception exception : exceptions) {
LOG.error(exception.getMessage(), exception);
}// for
}// if aStatus != null && isException
LOG.info("===== Client Initialization Complete =====");
}
示例11: checkForError
import org.apache.uima.collection.EntityProcessStatus; //导入依赖的package包/类
/**
* Check for an error in the return status of the processed CAS. Return true
* if there is an error.
*
* @param aCas CAS that was processed
* @param aStatus Status object that contains the exception if one is thrown
* @return True if an error was returned, False otherwise
*/
protected boolean checkForError(CAS aCas, EntityProcessStatus aStatus) {
if (aStatus != null && aStatus.isException()) {
List<Exception> exceptions = aStatus.getExceptions();
String errors = "";
this.lastException = "";
for (Exception exception : exceptions) {
Writer result = new StringWriter();
PrintWriter printWriter = new PrintWriter(result);
exception.printStackTrace(printWriter);
errors += result.toString() + "\n";
errors += exception.toString() + "\n---\n";
}// for
this.lastException = errors;
// Write exception out to file if the output directory is set.
if (logErrors) {
try {
LOG.error("ERROR processing CAS: " + this.getReferenceLocation(aCas.getJCas()) + "\n" + errors);
} catch (CASException e) {
e.printStackTrace();
}
}// if
return true;
}// if aStatus != null && isException
return false;
}
示例12: initializationComplete
import org.apache.uima.collection.EntityProcessStatus; //导入依赖的package包/类
/**
* Called once client initialization is complete.
*
* @param aStatus the status of the processing.
* @see UimaAsBaseCallbackListener#initializationComplete(EntityProcessStatus)
*/
@Override
public void initializationComplete(EntityProcessStatus aStatus) {
super.initializationComplete(aStatus);
if (includeHeader)
try {
writeHeaders();
} catch (IOException e) {
LOG.error("Error writing the headers!", e);
}
}
示例13: collectionProcessComplete
import org.apache.uima.collection.EntityProcessStatus; //导入依赖的package包/类
/**
* @param aStatus the status of the processing. This object contains a record of any Exception that occurred, as well as timing information.
* @see org.apache.uima.aae.client.UimaAsBaseCallbackListener#collectionProcessComplete(org.apache.uima.collection.EntityProcessStatus)
*/
@Override
public void collectionProcessComplete(EntityProcessStatus aStatus) {
super.collectionProcessComplete(aStatus);
try {
writer.flush();
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
示例14: entityProcessComplete
import org.apache.uima.collection.EntityProcessStatus; //导入依赖的package包/类
/**
* @param aCas the CAS containing the processed entity and the analysis results
* @param aStatus the status of the processing. This object contains a record of any Exception that occurred, as well as timing information.
* @see UimaAsBaseCallbackListener#entityProcessComplete(CAS, EntityProcessStatus)
*/
@Override
public void entityProcessComplete(CAS aCas, EntityProcessStatus aStatus) {
super.entityProcessComplete(aCas, aStatus);
String documentText = aCas.getDocumentText();
logger.info(documentText);
}
示例15: entityProcessComplete
import org.apache.uima.collection.EntityProcessStatus; //导入依赖的package包/类
/**
* Called when the processing of a Document is completed. <br>
* The process status can be looked at and corresponding actions taken.
*
* @param aCas
* CAS corresponding to the completed processing
* @param aStatus
* EntityProcessStatus that holds the status of all the events
* for aEntity
*/
public void entityProcessComplete(CAS aCas, EntityProcessStatus aStatus) {
// if there is an error above the individual document level,
// an entityProcessStatus is created with a null value for entity
if (aCas == null) {
for (int i = 0; i < aStatus.getFailedComponentNames().size(); i++) {
LOG.info("[{}] FailedComponentNames", aStatus
.getFailedComponentNames().get(i));
}
for (int i = 0; i < aStatus.getExceptions().size(); i++) {
LOG.info("[{}] Exceptions", aStatus.getExceptions().get(i));
}
return;
}
try {
entityCount++;
// FIXME int dataSize = 0;
// // get size here
// Type t = aCas.getTypeSystem().getType("uima.cpm.FileLocation");
// Feature f = t.getFeatureByBaseName("DocumentSize");
// FSIterator fsI = aCas.getAnnotationIndex(t).iterator();
// if (fsI.isValid()) {
// dataSize = fsI.get().getIntValue(f);
// }
//
// size += dataSize;
// to handle exceptions occured in any of the components for the
// entity
if (aStatus.isException()) {
for (int q = 0; q < aStatus.getExceptions().size(); q++) {
Exception e = (Exception) aStatus.getExceptions().get(q);
e.printStackTrace();
}
}
} catch (Exception io) {
UIMAFramework.getLogger(this.getClass()).log(Level.WARNING, "", io);
}
}