当前位置: 首页>>代码示例>>Java>>正文


Java CASException类代码示例

本文整理汇总了Java中org.apache.uima.cas.CASException的典型用法代码示例。如果您正苦于以下问题:Java CASException类的具体用法?Java CASException怎么用?Java CASException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CASException类属于org.apache.uima.cas包,在下文中一共展示了CASException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: process

import org.apache.uima.cas.CASException; //导入依赖的package包/类
@Override
   public void process( final JCas jcas ) throws AnalysisEngineProcessException {

      final String patient = Long.toString( SourceMetadataUtil.getPatientNum( jcas ) );
      final SourceData sourceData = SourceMetadataUtil.getSourceData( jcas );
      final String encounter = sourceData==null?"null":sourceData.getSourceEncounterId();
      final String providerId = sourceData==null?"null":SourceMetadataUtil.getProviderId( sourceData );
      // source date not used ???
//      final String sourceDate = sourceData.getSourceOriginalDate();
      JCas deidView = null;
      try{
        deidView = jcas.getView(DEID_VIEW);
      }catch(CASException e){
        throw new AnalysisEngineProcessException(e);
      }
      final Collection<String> conceptLines = createConceptLines( deidView, patient, encounter, providerId );

      final File outputFile = new File( _outputRootDir, encounter );
      saveAnnotations( outputFile, conceptLines );

   }
 
开发者ID:tmills,项目名称:ctakes-docker,代码行数:22,代码来源:I2b2ReadyFileWriter.java

示例2: getNext

import org.apache.uima.cas.CASException; //导入依赖的package包/类
@Override
public void getNext(CAS aCAS)
    throws IOException, CollectionException
{
    super.getNext(aCAS);

    JCas jcas;
    try {
        jcas = aCAS.getJCas();
        JCasId id = new JCasId(jcas);
        id.setId(jcasId++);
        id.addToIndexes();
    }
    catch (CASException e) {
        throw new CollectionException();
    }

    TextClassificationOutcome outcome = new TextClassificationOutcome(jcas);
    outcome.setOutcome(getTextClassificationOutcome(jcas));
    outcome.addToIndexes();

    if (!suppress) {
        new TextClassificationTarget(jcas, 0, jcas.getDocumentText().length()).addToIndexes();
    }
}
 
开发者ID:Horsmann,项目名称:FlexTag,代码行数:26,代码来源:TestReaderSingleLabel.java

示例3: 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();
	}
}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:23,代码来源:MapNameToIDSlot_AE.java

示例4: initializeFromWrappedMention

import org.apache.uima.cas.CASException; //导入依赖的package包/类
@Override
protected void initializeFromWrappedMention(Object... wrappedObjectPlusGlobalVars) {
	if (wrappedObjectPlusGlobalVars.length == 1) {
		Object wrappedObject = wrappedObjectPlusGlobalVars[0];
		if (wrappedObject instanceof CCPFloatSlotMention) {
			wrappedSM = (CCPFloatSlotMention) wrappedObject;
			try {
				jcas = wrappedSM.getCAS().getJCas();
			} catch (CASException e) {
				throw new RuntimeException(e);
			}
		} else {
			throw new KnowledgeRepresentationWrapperException(
					"Expected CCPNonComplexSlotMention. Cannot wrap class " + wrappedObject.getClass().getName()
							+ " inside a WrappedCCPFloatSlotMention.");
		}
	} else {
		throw new KnowledgeRepresentationWrapperException(
				"Single input parameter expected for WrappedCCPFloatMention. Instead, observed "
						+ wrappedObjectPlusGlobalVars.length + " parameter(s)");
	}
}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:23,代码来源:WrappedCCPFloatSlotMention.java

示例5: initializeFromWrappedMention

import org.apache.uima.cas.CASException; //导入依赖的package包/类
@Override
protected void initializeFromWrappedMention(Object... wrappedObjectPlusGlobalVars) {
	if (wrappedObjectPlusGlobalVars.length == 1) {
		Object wrappedObject = wrappedObjectPlusGlobalVars[0];
		if (wrappedObject instanceof CCPStringSlotMention) {
			wrappedSM = (CCPStringSlotMention) wrappedObject;
			try {
				jcas = wrappedSM.getCAS().getJCas();
			} catch (CASException e) {
				throw new RuntimeException(e);
			}
		} else {
			throw new KnowledgeRepresentationWrapperException(
					"Expected CCPNonComplexSlotMention. Cannot wrap class " + wrappedObject.getClass().getName()
							+ " inside a WrappedCCPNonComplexSlotMention.");
		}
	} else {
		throw new KnowledgeRepresentationWrapperException(
				"Single input parameter expected for WrappedCCPComplexSlotMention. Instead, observed "
						+ wrappedObjectPlusGlobalVars.length + " parameter(s)");
	}
}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:23,代码来源:WrappedCCPStringSlotMention.java

示例6: initializeFromWrappedMention

import org.apache.uima.cas.CASException; //导入依赖的package包/类
@Override
protected void initializeFromWrappedMention(Object... wrappedObjectPlusGlobalVars) {
	if (wrappedObjectPlusGlobalVars.length == 1) {
		Object wrappedObject = wrappedObjectPlusGlobalVars[0];
		if (wrappedObject instanceof CCPIntegerSlotMention) {
			wrappedSM = (CCPIntegerSlotMention) wrappedObject;
			try {
				jcas = wrappedSM.getCAS().getJCas();
			} catch (CASException e) {
				throw new RuntimeException(e);
			}
		} else {
			throw new KnowledgeRepresentationWrapperException(
					"Expected CCPNonComplexSlotMention. Cannot wrap class " + wrappedObject.getClass().getName()
							+ " inside a WrappedCCPIntegerSlotMention.");
		}
	} else {
		throw new KnowledgeRepresentationWrapperException(
				"Single input parameter expected for WrappedCCPIntegerMention. Instead, observed "
						+ wrappedObjectPlusGlobalVars.length + " parameter(s)");
	}
}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:23,代码来源:WrappedCCPIntegerSlotMention.java

示例7: initializeFromWrappedMention

import org.apache.uima.cas.CASException; //导入依赖的package包/类
@Override
protected void initializeFromWrappedMention(Object... wrappedObjectPlusGlobalVars) {
	if (wrappedObjectPlusGlobalVars.length == 1) {
		Object wrappedObject = wrappedObjectPlusGlobalVars[0];
		if (wrappedObject instanceof CCPComplexSlotMention) {
			wrappedCSM = (CCPComplexSlotMention) wrappedObject;
			try {
				jcas = wrappedCSM.getCAS().getJCas();
			} catch (CASException e) {
				throw new RuntimeException(e);
			}
		} else {
			throw new KnowledgeRepresentationWrapperException("Expected CCPComplexSlotMention. Cannot wrap class "
					+ wrappedObject.getClass().getName() + " inside a WrappedCCPComplexSlotMention.");
		}
	} else {
		throw new KnowledgeRepresentationWrapperException(
				"Single input parameter expected for WrappedCCPComplexSlotMention. Instead, observed "
						+ wrappedObjectPlusGlobalVars.length + " parameter(s)");
	}
}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:22,代码来源:WrappedCCPComplexSlotMention.java

示例8: initializeFromWrappedMention

import org.apache.uima.cas.CASException; //导入依赖的package包/类
@Override
protected void initializeFromWrappedMention(Object... wrappedObjectPlusGlobalVars) {
	if (wrappedObjectPlusGlobalVars.length == 1) {
		Object wrappedObject = wrappedObjectPlusGlobalVars[0];
		if (wrappedObject instanceof CCPDoubleSlotMention) {
			wrappedSM = (CCPDoubleSlotMention) wrappedObject;
			try {
				jcas = wrappedSM.getCAS().getJCas();
			} catch (CASException e) {
				throw new RuntimeException(e);
			}
		} else {
			throw new KnowledgeRepresentationWrapperException(
					"Expected CCPNonComplexSlotMention. Cannot wrap class " + wrappedObject.getClass().getName()
							+ " inside a WrappedCCPDoubleSlotMention.");
		}
	} else {
		throw new KnowledgeRepresentationWrapperException(
				"Single input parameter expected for WrappedCCPDoubleMention. Instead, observed "
						+ wrappedObjectPlusGlobalVars.length + " parameter(s)");
	}
}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:23,代码来源:WrappedCCPDoubleSlotMention.java

示例9: copyCCPPrimitiveSlotMention

import org.apache.uima.cas.CASException; //导入依赖的package包/类
private static CCPPrimitiveSlotMention copyCCPPrimitiveSlotMention(CCPPrimitiveSlotMention fromSM)
		throws CASException {
	JCas jcas = fromSM.getCAS().getJCas();
	try {
		if (fromSM instanceof CCPStringSlotMention) {
			return CCPPrimitiveSlotMentionFactory.createCCPStringSlotMention(fromSM.getMentionName(),
					convertToCollection(((CCPStringSlotMention) fromSM).getSlotValues()), jcas);
		} else if (fromSM instanceof CCPIntegerSlotMention) {
			return CCPPrimitiveSlotMentionFactory.createCCPIntegerSlotMention(fromSM.getMentionName(),
					convertToCollection(((CCPIntegerSlotMention) fromSM).getSlotValues()), jcas);
		} else if (fromSM instanceof CCPFloatSlotMention) {
			return CCPPrimitiveSlotMentionFactory.createCCPFloatSlotMention(fromSM.getMentionName(),
					convertToCollection(((CCPFloatSlotMention) fromSM).getSlotValues()), jcas);
		} else if (fromSM instanceof CCPBooleanSlotMention) {
			return CCPPrimitiveSlotMentionFactory.createCCPBooleanSlotMention(fromSM.getMentionName(),
					((CCPBooleanSlotMention) fromSM).getSlotValue(), jcas);
		} else {
			throw new KnowledgeRepresentationWrapperException("Unknown CCP Primitive Slot Mention type: "
					+ fromSM.getClass().getName() + " Cannot copy CCPPrimitiveSlotMention.");
		}

	} catch (KnowledgeRepresentationWrapperException e) {
		throw new CASException(e);
	}
}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:26,代码来源:UIMA_Util.java

示例10: addSlotValue

import org.apache.uima.cas.CASException; //导入依赖的package包/类
public static void addSlotValue(CCPClassMention ccpClassMention, String slotMentionName,
		CCPClassMention slotFillerCM) throws CASException {
	CCPComplexSlotMention ccpComplexSlotMention = (CCPComplexSlotMention) UIMA_Util.getSlotMentionByName(
			ccpClassMention, slotMentionName);
	if (ccpComplexSlotMention == null) { // then we need to create a new
		// CCPNonComplexSlotMention
		JCas jcas = ccpClassMention.getCAS().getJCas();
		ccpComplexSlotMention = new CCPComplexSlotMention(jcas);
		ccpComplexSlotMention.setMentionName(slotMentionName);
		FSArray classMentions = new FSArray(jcas, 1);
		classMentions.set(0, slotFillerCM);
		ccpComplexSlotMention.setClassMentions(classMentions);
		addSlotMention(ccpClassMention, ccpComplexSlotMention);
	} else {
		addClassMentionAsCSMSlotFiller(ccpComplexSlotMention, slotFillerCM);
	}
}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:18,代码来源:UIMA_Util.java

示例11: 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());
}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:26,代码来源:UIMA_UtilTest.java

示例12: testGetSlotMentionByName

import org.apache.uima.cas.CASException; //导入依赖的package包/类
/**
 * Test the getSlotMentionByName() method
 * 
 * @throws CASException
 */
@Test
public void testGetSlotMentionByName() throws CASException {
	// if the slotMention does not exist, it should return null
	assertNull(UIMA_Util.getSlotMentionByName(testCCPClassMention, "slotMentionName"));

	// add a slot value - and thereby add a slot
	UIMA_Util.addSlotValue(testCCPClassMention, "slotMentionName", "slotValue");

	// it should now return a slot mention
	CCPStringSlotMention ccpNonComplexSlotMention = (CCPStringSlotMention) UIMA_Util.getSlotMentionByName(
			testCCPClassMention, "slotMentionName");
	assertNotNull(ccpNonComplexSlotMention);

	// and the value of the returned slot should equal "slotValue"
	assertEquals("slotValue", UIMA_Util.getFirstSlotValue(ccpNonComplexSlotMention));

	// add another slot value
	UIMA_Util.addSlotValue(testCCPClassMention, "slotMentionName", "slotValue2");
	// and now there should be two slot values
	assertEquals(2, ccpNonComplexSlotMention.getSlotValues().size());

	// add another slot value - and thereby add a new slot
	UIMA_Util.addSlotValue(testCCPClassMention, "slot2MentionName", "slot2Value");
	assertEquals(2, testCCPClassMention.getSlotMentions().size());
}
 
开发者ID:UCDenver-ccp,项目名称:ccp-nlp,代码行数:31,代码来源:UIMA_UtilTest.java

示例13: process

import org.apache.uima.cas.CASException; //导入依赖的package包/类
@Override
public void process(JCas jcas) throws AnalysisEngineProcessException {
	JCas other;
	try {
		other = jcas.getView(viewName);
		for (Origin origin : JCasUtil.select(other, Origin.class)) {
			int relativ = -origin.getBegin() + origin.getOffset();
			for (Annotation src : JCasUtil.selectCovered(annotationClass, origin)) {
				int tgtBegin = src.getBegin() + relativ;
				int tgtEnd = src.getEnd() + relativ;
				for (Annotation tgt : JCasUtil.selectCovered(jcas, annotationClass, tgtBegin, tgtEnd)) {
					if (tgtBegin == tgt.getBegin() && tgtEnd == tgt.getEnd()) {
						Feature feature = tgt.getType().getFeatureByBaseName(featureName);
						if (feature.getRange().getName().equalsIgnoreCase("uima.cas.String")) {
							tgt.setStringValue(feature, src.getStringValue(feature));
						}
					}
				}
			}
		}
	} catch (CASException e) {
		throw new AnalysisEngineProcessException(e);
	}
}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:25,代码来源:MapBackFeature.java

示例14: 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();
}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:35,代码来源:PrepareClearTk.java

示例15: process

import org.apache.uima.cas.CASException; //导入依赖的package包/类
@Override
public void process(JCas jcas) throws AnalysisEngineProcessException {
	JCas other;
	try {
		other = jcas.getView(viewName);
		for (Origin origin : JCasUtil.select(other, Origin.class)) {
			int relativ = -origin.getBegin() + origin.getOffset();
			for (Annotation src : JCasUtil.selectCovered(annotationClass, origin)) {
				Annotation tgt = AnnotationFactory.createAnnotation(jcas, src.getBegin() + relativ,
						src.getEnd() + relativ, annotationClass);
				for (Feature feature : src.getType().getFeatures()) {
					if (feature.getRange().isPrimitive()) {
						if (feature.getRange().getName().equalsIgnoreCase("uima.cas.String")) {
							tgt.setStringValue(feature, src.getStringValue(feature));
						}
					}
				}
			}
		}
	} catch (CASException e) {
		throw new AnalysisEngineProcessException(e);
	}
}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:24,代码来源:MapBackAnnotations.java


注:本文中的org.apache.uima.cas.CASException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。