本文整理汇总了Java中org.apache.uima.cas.CASException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java CASException.printStackTrace方法的具体用法?Java CASException.printStackTrace怎么用?Java CASException.printStackTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.uima.cas.CASException
的用法示例。
在下文中一共展示了CASException.printStackTrace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import org.apache.uima.cas.CASException; //导入方法依赖的package包/类
@Override
public void process(JCas jcas)
throws AnalysisEngineProcessException {
try {
FSIterator ccptaIterator = jcas.getAnnotationIndex(CCPTextAnnotation.type).iterator();
while (ccptaIterator.hasNext()) {
CCPTextAnnotation ccpta = (CCPTextAnnotation) ccptaIterator.next();
String ccptaMentionName = ccpta.getClassMention().getMentionName();
if (ccptaMentionName != null) {
Matcher m = mentionTypeInPattern.matcher(ccptaMentionName);
if ( m.matches() ) {
CCPClassMention ccpcm = ccpta.getClassMention();
ccpcm.setMentionName(mentionTypeOut);
UIMA_Util.addSlotValue(ccpcm, "ID", ccptaMentionName);
}
}
}
} catch (CASException e) {
e.printStackTrace();
throw new AnalysisEngineProcessException();
}
}
示例2: testSwapCCPTextAnnotation2CCPTextAnnotation
import org.apache.uima.cas.CASException; //导入方法依赖的package包/类
/**
* Test the transfer of information from one UIMA TextAnnotation (CCPTextAnnotation) to another
*
*/
@Test
public void testSwapCCPTextAnnotation2CCPTextAnnotation() {
CCPTextAnnotation swapToAnnotation = new CCPTextAnnotation(jcas);
try {
UIMA_Util.swapAnnotationInfo(testCCPTextAnnotation1, swapToAnnotation);
} catch (CASException ce) {
ce.printStackTrace();
fail("CASException while swapping annotation info");
}
assertEquals(testCCPTextAnnotation1.getAnnotationID(), swapToAnnotation.getAnnotationID());
assertEquals(testCCPTextAnnotation1.getBegin(), swapToAnnotation.getBegin());
assertEquals(testCCPTextAnnotation1.getEnd(), swapToAnnotation.getEnd());
assertEquals(testCCPTextAnnotation1.getDocumentSectionID(), swapToAnnotation.getDocumentSectionID());
assertEquals(testCCPTextAnnotation1.getNumberOfSpans(), swapToAnnotation.getNumberOfSpans());
assertEquals(testCCPTextAnnotation1.getSpans().size(), swapToAnnotation.getSpans().size());
assertEquals(testCCPTextAnnotation1.getClassMention().getMentionName(), swapToAnnotation.getClassMention()
.getMentionName());
assertEquals(testCCPTextAnnotation1.getClassMention().getSlotMentions().size(), swapToAnnotation
.getClassMention().getSlotMentions().size());
}
示例3: process
import org.apache.uima.cas.CASException; //导入方法依赖的package包/类
@Override
public void process(JCas jcas) throws AnalysisEngineProcessException {
JCas newView;
try {
newView = jcas.createView(viewName);
} catch (CASException e) {
e.printStackTrace();
throw new AnalysisEngineProcessException(e);
}
JCasBuilder builder = new JCasBuilder(newView);
for (Annotation a : JCasUtil.select(jcas, annotationClass)) {
int relativ = -a.getBegin() + builder.getPosition();
Origin o = builder.add(a.getCoveredText(), Origin.class);
o.setOffset(a.getBegin());
for (Class<Annotation> subClass : subAnnotations) {
for (Annotation sub : JCasUtil.selectCovered(subClass, a)) {
int tgtBegin = sub.getBegin() + relativ, tgtEnd = sub.getEnd() + relativ;
Annotation tgt = AnnotationFactory.createAnnotation(newView, sub.getBegin() + relativ,
sub.getEnd() + relativ, subClass);
for (Feature feature : sub.getType().getFeatures()) {
if (feature.getRange().isPrimitive())
tgt.setFeatureValueFromString(feature, sub.getFeatureValueAsString(feature));
}
tgt.setBegin(tgtBegin);
tgt.setEnd(tgtEnd);
}
}
}
builder.close();
}
示例4: getTheArtifactName
import org.apache.uima.cas.CASException; //导入方法依赖的package包/类
/**
* Get the name of the artifact whatever it appears in any annotation index of associated view
* @param aJCas
* @return
* @throws AnalysisEngineProcessException
* @throws CASRuntimeException
*/
public static String getTheArtifactName(JCas aJCas) throws CASRuntimeException, AnalysisEngineProcessException {
String artifactName = "";
try {
Iterator<JCas> jCasViewIter = aJCas.getViewIterator();
while (jCasViewIter.hasNext()) {
JCas aJCasView = jCasViewIter.next();
String currentArtifactViewName = getArtifactViewName(aJCasView);
//System.out.println("Debug: one view of the current JCas >"+aJCasView.getViewName()+"< and the artifact name is >"+currentArtifactViewName+"<");
if (currentArtifactViewName != null)
if (!currentArtifactViewName.equalsIgnoreCase("")) artifactName = currentArtifactViewName;
}
} catch (CASException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
return artifactName;
}
示例5: getTheArtifactName
import org.apache.uima.cas.CASException; //导入方法依赖的package包/类
/**
* Get the name of the artifact whatever it appears in any annotation index of associated view
* @param aJCas
* @return
* @throws AnalysisEngineProcessException
* @throws CASRuntimeException
*/
public static String getTheArtifactName(JCas aJCas)
throws CASRuntimeException, AnalysisEngineProcessException
{
/* 217 */ String artifactName = "";
try {
/* 219 */ Iterator<JCas> jCasViewIter = aJCas.getViewIterator();
/* 221 */ while (jCasViewIter.hasNext()) {
/* 222 */ JCas aJCasView = (JCas)jCasViewIter.next();
/* 223 */ String currentArtifactViewName = getArtifactViewName(aJCasView);
/* 226 */ if ((currentArtifactViewName != null) &&
/* 227 */ (!currentArtifactViewName.equalsIgnoreCase(""))) artifactName = currentArtifactViewName;
}
}
catch (CASException e1)
{
/* 232 */ e1.printStackTrace();
}
/* 235 */ return artifactName;
}
示例6: copySofaData
import org.apache.uima.cas.CASException; //导入方法依赖的package包/类
/**
* Copy the sofa data, the mimeType and the DocumentLanguage
*
* @param targetView
* @param aFromViewName
*/
public void copySofaData (JCas targetView, String aFromViewName) {
try {
String sofaMime = sourceJCas.getView(aFromViewName).getCas().getSofa().getSofaMime();
if (sourceJCas.getView(aFromViewName).getCas().getDocumentText() != null) {
targetView.setSofaDataString(sourceJCas.getView(aFromViewName).getCas().getDocumentText(), sofaMime);
if (debug) System.out.println("Debug: ViewRenamer next targetView.setSofaDataString(sourceJCas.getView(getFromViewName()).getCas().getDocumentText(), sofaMime);");
} else if (sourceJCas.getView(aFromViewName).getCas().getSofaDataURI() != null) {
targetView.setSofaDataURI(sourceJCas.getView(aFromViewName).getCas().getSofaDataURI(), sofaMime);
if (debug) System.out.println("Debug: ViewRenamer next targetView.setSofaDataURI(sourceJCas.getView(getFromViewName()).getCas().getSofaDataURI(), sofaMime);");
} else if (sourceJCas.getView(aFromViewName).getCas().getSofaDataArray() != null) {
//targetView.setSofaDataArray(copier.copyFs(sourceJCas.getView(getFromViewName()).getCas().getSofaDataArray()), sofaMime);
targetView.setSofaDataArray(copyFs(sourceJCas.getView(aFromViewName).getCas().getSofaDataArray(), aFromViewName), sofaMime);
if (debug) System.out.println("Debug: ViewRenamer next targetView.setSofaDataArray(copyFs(sourceJCas.getView(getFromViewName()).getCas().getSofaDataArray()), sofaMime);");
}
// nh
// je suppose q le Sofa (et ses traits mimeType, sofaString... ) et le DocumentAnnotation (et son trait sofa et langage) sont définis à ce moment là et que l'on a pas besoin de le faire
targetView.setDocumentLanguage(sourceJCas.getView(aFromViewName).getCas().getDocumentLanguage());
} catch (CASException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例7: getNext
import org.apache.uima.cas.CASException; //导入方法依赖的package包/类
public void getNext(CAS aCas) throws IOException, CollectionException {
JCas jcas;
try {
Tuple nextTuple = bagIterator.next();
jcas = aCas.getJCas();
DocumentID documentIDAnnotation = new DocumentID(jcas);
String docID = (String) nextTuple.get(0);
documentIDAnnotation.setDocumentID(docID);
documentIDAnnotation.addToIndexes();
String text = (String) nextTuple.get(1);
jcas.setDocumentText(text);
} catch (CASException e) {
e.printStackTrace();
} finally {
numTuplesProcessed++;
}
}
示例8: createComplexSlotMention
import org.apache.uima.cas.CASException; //导入方法依赖的package包/类
public ComplexSlotMention createComplexSlotMention(String slotMentionName) {
CCPComplexSlotMention ccpCSM = null;
try {
ccpCSM = new CCPComplexSlotMention(wrappedCM.getCAS().getJCas());
} catch (CASException e) {
e.printStackTrace();
}
ccpCSM.setMentionName(slotMentionName);
return new WrappedCCPComplexSlotMention(ccpCSM);
}
示例9: getAnnotationProperties
import org.apache.uima.cas.CASException; //导入方法依赖的package包/类
public static <T extends AnnotationMetadataProperty> Collection<T> getAnnotationProperties(
CCPTextAnnotation ccpTA, Class<T> annotationPropertyClass) {
try {
JCas jcas = ccpTA.getCAS().getJCas();
return getAnnotationProperties(ccpTA, annotationPropertyClass, jcas);
} catch (CASException e) {
e.printStackTrace();
return null;
}
}
示例10: testTrimCCPTextAnnotation
import org.apache.uima.cas.CASException; //导入方法依赖的package包/类
@Test
public void testTrimCCPTextAnnotation() {
// System.out.println("BEFORE TRIM: " + testCcpTA.getCoveredText());
try {
UIMA_Annotation_Util.trimCCPTextAnnotation(testCcpTA);
} catch (CASException e) {
e.printStackTrace();
fail("Test failed.. exception while trimming CCPTextAnnotation");
}
// System.out.println("AFTER TRIM: " + testCcpTA.getCoveredText());
assertEquals("Annotation text", testCcpTA.getCoveredText());
}
示例11: addWSTokensToView
import org.apache.uima.cas.CASException; //导入方法依赖的package包/类
public static void addWSTokensToView(JCas aCas, String viewName)
{
try {
JCas theView = aCas.getView(viewName);
String enText = theView.getDocumentText();
StringTokenizer st = new StringTokenizer(enText);
int pos=0;
while(st.hasMoreTokens())
{
String thisTok = st.nextToken();
int begin = enText.indexOf(thisTok, pos);
int end = begin + thisTok.length();
pos = end;
Token tokenAnnot = new Token(theView); // note that it is from the "View", not top CAS...
tokenAnnot.setBegin(begin);
tokenAnnot.setEnd(end);
tokenAnnot.addToIndexes(); //.. so this attach itself to "View Index", and it can be itereated from the View.
}
}
catch (CASException e)
{
//if no such view name exist in the CAS, JCAS.getView() raises an exception.
e.printStackTrace();
}
}
示例12: checkForError
import org.apache.uima.cas.CASException; //导入方法依赖的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;
}
示例13: copySofaData
import org.apache.uima.cas.CASException; //导入方法依赖的package包/类
/**
* Copy the sofa data, the mimeType and the DocumentLanguage
*
* @param targetView
* @param aFromViewName
*/
public void copySofaData(CAS targetView, String aFromViewName) {
try {
String sofaMime = sourceJCas.getView(aFromViewName).getCas()
.getSofa().getSofaMime();
if (sourceJCas.getView(aFromViewName).getCas().getDocumentText() != null) {
targetView.setSofaDataString(sourceJCas.getView(aFromViewName)
.getCas().getDocumentText(), sofaMime);
// if (debug)
// System.out.println("Debug: ViewRenamer next targetView.setSofaDataString(sourceJCas.getView(getFromViewName()).getCas().getDocumentText(), sofaMime);");
} else if (sourceJCas.getView(aFromViewName).getCas()
.getSofaDataURI() != null) {
targetView.setSofaDataURI(sourceJCas.getView(aFromViewName)
.getCas().getSofaDataURI(), sofaMime);
// if (debug)
// System.out.println("Debug: ViewRenamer next targetView.setSofaDataURI(sourceJCas.getView(getFromViewName()).getCas().getSofaDataURI(), sofaMime);");
} else if (sourceJCas.getView(aFromViewName).getCas()
.getSofaDataArray() != null) {
// targetView.setSofaDataArray(copier.copyFs(sourceJCas.getView(getFromViewName()).getCas().getSofaDataArray()),
// sofaMime);
targetView.setSofaDataArray(
copyFs(sourceJCas.getView(aFromViewName).getCas()
.getSofaDataArray(), aFromViewName), sofaMime);
// if (debug)
// System.out.println("Debug: ViewRenamer next targetView.setSofaDataArray(copyFs(sourceJCas.getView(getFromViewName()).getCas().getSofaDataArray()), sofaMime);");
}
// nh
// je suppose q le Sofa (et ses traits mimeType, sofaString... ) et
// le DocumentAnnotation (et son trait sofa et langage) sont définis
// à ce moment là et que l'on a pas besoin de le faire
targetView.setDocumentLanguage(sourceJCas.getView(aFromViewName)
.getCas().getDocumentLanguage());
} catch (CASException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例14: processCas
import org.apache.uima.cas.CASException; //导入方法依赖的package包/类
/**
* Process the given CAS object.
*/
public void processCas(CAS cas) {
try {
JCas jcas = cas.getJCas();
} catch (CASException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例15: printTHInfo
import org.apache.uima.cas.CASException; //导入方法依赖的package包/类
@SuppressWarnings("unused")
public static void printTHInfo(JCas aCas)
{
try {
JCas tView = aCas.getView("TextView");
JCas hView = aCas.getView("HypothesisView"); // again, if the view names are not there, it will raise exceptions
//Now we need to get Entailment.Pair, to find out about
//the entailment problem.
//If the goal type is an annotation that has begin / end (most of them. Tokens, POSes, NERs ..)
//1) use getAnnotationsIndex and iterate over them. It returns an ordered iterator.
//If the target type is *not* annotations (i.e. EntailmentMetadata, Pair)
//2) getJFSIndexRepository().getAllIndexedFS()
//This can be used to fetch any type instances. (including annotation and non annotation)
//Unlike getAnnotationsIndex, the returned data has no orders.
//(Only a few ECXITEMENT types are non-annotation: including Entailment.EntailmentMetadata, and Entailment.Pair.)
//Since we need to get Entailment.Pair, use getAllIndexedFS
FSIterator<TOP> pairIter = aCas.getJFSIndexRepository().getAllIndexedFS(Pair.type);
//note that we get it from outside "wrapping" CAS, not from the view CAS.
Pair p=null;
int i=0;
System.out.println("====");
while(pairIter.hasNext())
{
p = (Pair) pairIter.next();
i++;
System.out.printf("PairID: %s\n", p.getPairID());
System.out.printf("Text of the pair: %s\n", p.getText().getCoveredText());
//note that Text annotation is actually on TextView.
System.out.printf("Hypothesis of the pair: %s\n", p.getHypothesis().getCoveredText());
//note that Hypothesis annotation is actually on HypothesisView. You can access it from pair.
System.out.printf("GoldAnswer of the pair: %s\n", p.getGoldAnswer());
}
System.out.printf("----\nThe CAS had %d pairs.\n====\n", i);
}
catch (CASException e)
{
e.printStackTrace();
}
}