本文整理了Java中org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation
类的一些代码示例,展示了IdentifiedAnnotation
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IdentifiedAnnotation
类的具体详情如下:
包路径:org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation
类名称:IdentifiedAnnotation
[英]Any span of text that has been discovered or flagged for some reason, such as a Named Entity. Allows for mapping to an ontology. Generalized from cTAKES: org.apache.ctakes.typesystem.type.IdentifiedAnnotation. Updated by JCasGen Mon Apr 17 15:43:30 EDT 2017 XML source: /private/tmp/murali/ctakes/4.0.0/target/checkout/ctakes-ytex-uima/target/jcasgen/typesystem.xml
[中]由于某种原因(如命名实体)发现或标记的任何文本范围。允许映射到本体。从cTAKES:org推广。阿帕奇。克塔克斯。打字系统。类型识别注释。JCasGen于2017年4月17日星期一15:43:30更新XML源:/private/tmp/murali/ctakes/4.0.0/target/checkout/ctakes-ytex-uima/target/JCasGen/typesystem。xml
代码示例来源:origin: org.apache.ctakes/ctakes-core
private Entity( final IdentifiedAnnotation annotation ) {
_begin = annotation.getBegin();
_end = annotation.getEnd();
_coveredText = annotation.getCoveredText();
_polarity = annotation.getPolarity();
_uncertainty = annotation.getUncertainty();
_conditional = annotation.getConditional();
_generic = annotation.getGeneric();
_subject = annotation.getSubject();
_historyOf = annotation.getHistoryOf();
}
代码示例来源:origin: apache/ctakes
IdentifiedAnnotation m = (IdentifiedAnnotation) ctor.newInstance(jCas);
m.setBegin(mention.getBegin());
m.setEnd(mention.getEnd());
for (Selector s : msg.keySet()) {
if (!hypothAttr.contains(s)) {
switch (s) {
case CONDITIONAL:
m.setConditional(mention.getConditional());
break;
case GENERIC:
m.setGeneric(mention.getGeneric());
break;
case HISTORYOF:
m.setHistoryOf(mention.getHistoryOf());
break;
case POLARITY:
m.setPolarity(mention.getPolarity());
break;
case SUBJECT:
m.setSubject(mention.getSubject());
break;
case UNCERTAINTY:
m.setUncertainty(mention.getUncertainty());
break;
m.addToIndexes(jCas);
代码示例来源:origin: apache/tika
String value = null;
if (property == CTAKESAnnotationProperty.BEGIN) {
value = Integer.toString(annotation.getBegin());
} else if (property == CTAKESAnnotationProperty.END) {
value = Integer.toString(annotation.getEnd());
} else if (property == CTAKESAnnotationProperty.CONDITIONAL) {
value = Boolean.toString(annotation.getConditional());
} else if (property == CTAKESAnnotationProperty.CONFIDENCE) {
value = Float.toString(annotation.getConfidence());
} else if (property == CTAKESAnnotationProperty.DISCOVERY_TECNIQUE) {
value = Integer.toString(annotation.getDiscoveryTechnique());
} else if (property == CTAKESAnnotationProperty.GENERIC) {
value = Boolean.toString(annotation.getGeneric());
} else if (property == CTAKESAnnotationProperty.HISTORY_OF) {
value = Integer.toString(annotation.getHistoryOf());
} else if (property == CTAKESAnnotationProperty.ID) {
value = Integer.toString(annotation.getId());
} else if (property == CTAKESAnnotationProperty.ONTOLOGY_CONCEPT_ARR) {
FSArray mentions = annotation.getOntologyConceptArr();
StringBuilder sb = new StringBuilder();
if (mentions != null) {
String polarity_pref = "POLARITY";
value = new StringBuilder(polarity_pref).append("=").
append(Integer.toString(annotation.getPolarity())).toString();
代码示例来源:origin: apache/tika
IdentifiedAnnotation annotation = iterator.next();
StringBuilder annotationBuilder = new StringBuilder();
annotationBuilder.append(annotation.getCoveredText());
if (annotationPros != null) {
for (CTAKESAnnotationProperty property : annotationPros) {
metadata.add(CTAKES_META_PREFIX + annotation.getType().getShortName(), annotationBuilder.toString());
代码示例来源:origin: apache/ctakes
mention.setBegin(original.getBegin());
mention.setEnd(original.getEnd());
mention.setConditional(original.getConditional());
mention.setConfidence(original.getConfidence());
mention.setDiscoveryTechnique(original.getDiscoveryTechnique());
mention.setGeneric(original.getGeneric());
mention.setOntologyConceptArr(original.getOntologyConceptArr());
mention.setPolarity(original.getPolarity());
mention.setSegmentID(original.getSegmentID());
mention.setSentenceID(original.getSentenceID());
mention.setSubject(original.getSubject());
mention.setTypeID(original.getTypeID());
mention.setUncertainty(original.getUncertainty());
mention.setHistoryOf(original.getHistoryOf());
mention.addToIndexes();
代码示例来源:origin: org.apache.ctakes/ctakes-assertion
/**
*
* @param goldAnnotation
* @param jcas
*/
private static void copyAnnotation(Annotation goldAnnotation, JCas jcas) {
Annotation newAnno;
if (goldAnnotation instanceof IdentifiedAnnotation) {
IdentifiedAnnotation ia = new IdentifiedAnnotation(jcas);
ia.setConditional(((IdentifiedAnnotation) goldAnnotation).getConditional());
ia.setConfidence(((IdentifiedAnnotation) goldAnnotation).getConfidence());
ia.setDiscoveryTechnique(((IdentifiedAnnotation)goldAnnotation).getDiscoveryTechnique());
ia.setGeneric(((IdentifiedAnnotation) goldAnnotation).getGeneric());
ia.setHistoryOf(((IdentifiedAnnotation) goldAnnotation).getHistoryOf());
ia.setPolarity(((IdentifiedAnnotation) goldAnnotation).getPolarity());
ia.setSegmentID(((IdentifiedAnnotation) goldAnnotation).getSegmentID());
ia.setSentenceID(((IdentifiedAnnotation) goldAnnotation).getSentenceID());
ia.setSubject(((IdentifiedAnnotation) goldAnnotation).getSubject());
ia.setTypeID(((IdentifiedAnnotation) goldAnnotation).getTypeID());
ia.setUncertainty(((IdentifiedAnnotation) goldAnnotation).getUncertainty());
newAnno = ia;
} else {
throw new RuntimeException("Unexpected class of object " + goldAnnotation.getClass());
}
newAnno.setBegin(goldAnnotation.getBegin());
newAnno.setEnd(goldAnnotation.getEnd());
newAnno.addToIndexes();
}
代码示例来源:origin: org.apache.ctakes/ctakes-dictionary-lookup-fast
annotation.setTypeID( cTakesSemantic );
annotation.setBegin( spanCuis.getKey().getStart() );
annotation.setEnd( spanCuis.getKey().getEnd() );
annotation.setDiscoveryTechnique( CONST.NE_DISCOVERY_TECH_DICT_LOOKUP );
annotation.setOntologyConceptArr( conceptArr );
annotation.addToIndexes();
代码示例来源:origin: apache/ctakes
Map<String, TOP> idAnnotationMap,
List<DelayedFeature> delayedFeatures) {
mention.setTypeID(typeID);
mention.setConfidence(1.0f);
mention.setDiscoveryTechnique(CONST.NE_DISCOVERY_TECH_GOLD_ANNOTATION);
mention.setPolarity(negation == null
? CONST.NE_POLARITY_NEGATION_ABSENT
: negation == true ? CONST.NE_POLARITY_NEGATION_PRESENT : CONST.NE_POLARITY_NEGATION_ABSENT);
if (status != null) {
if ("HistoryOf".equals(status)) {
mention.setHistoryOf(CONST.NE_HISTORY_OF_PRESENT);
} else if ("FamilyHistoryOf".equals(status)) {
mention.setHistoryOf(CONST.NE_HISTORY_OF_PRESENT);
mention.setSubject(CONST.ATTR_SUBJECT_FAMILY_MEMBER);
} else if ("Possible".equals(status)) {
mention.setUncertainty(CONST.NE_CERTAINTY_NEGATED);
} else {
throw new UnsupportedOperationException("Unknown status: " + status);
if (mention.getTypeID() == CONST.NE_TYPE_ID_DRUG) {
ontologyConcept = new OntologyConcept(jCas);
ontologyConcept.setCode(code);
mention.setOntologyConceptArr(new FSArray(jCas, 1));
mention.setOntologyConceptArr(0, ontologyConcept);
mention.addToIndexes();
代码示例来源:origin: apache/ctakes
private String getAttrValueString(IdentifiedAnnotation mention, Selector s) {
switch (s) {
case CONDITIONAL:
return String.valueOf(mention.getConditional());
case GENERIC:
return String.valueOf(mention.getGeneric());
case HISTORYOF:
return String.valueOf(mention.getHistoryOf());
case POLARITY:
return String.valueOf(mention.getPolarity());
case SUBJECT:
return String.valueOf(mention.getSubject());
case UNCERTAINTY:
return String.valueOf(mention.getUncertainty());
default:
return "?";
}
}
代码示例来源:origin: org.apache.ctakes/ctakes-ytex-uima
private void addNamedEntity(JCas jcas, int begin, int end,
Map<String, OntologyConcept> concepts, boolean bMedication,
Set<NegSpan> negSet) {
if (concepts.isEmpty())
return;
IdentifiedAnnotation neLast = bMedication ? new MedicationEventMention(
jcas) : new EntityMention(jcas);
neLast.setPolarity(negSet.contains(new NegSpan(begin, end)) ? CONST.NE_POLARITY_NEGATION_PRESENT
: CONST.NE_POLARITY_NEGATION_ABSENT);
neLast.setBegin(begin);
neLast.setEnd(end);
FSArray ocArr = new FSArray(jcas, concepts.size());
int ocArrIdx = 0;
for (OntologyConcept oc : concepts.values()) {
// set the cui field if this is in fact a cui
ocArr.set(ocArrIdx, oc);
ocArrIdx++;
}
neLast.setOntologyConceptArr(ocArr);
concepts.clear();
neLast.addToIndexes();
}
代码示例来源:origin: org.apache.ctakes/ctakes-relation-extractor
@Override
public List<Feature> extract(JCas jCas, IdentifiedAnnotation arg1, IdentifiedAnnotation arg2) throws AnalysisEngineProcessException {
List<Feature> features = new ArrayList<Feature>();
// entity1 ... entity2 scenario
if(arg1.getEnd() < arg2.getBegin()) {
features.add(new Feature("arg1_arg2", true));
}
// entity2 ... entity1 scenario
if(arg2.getEnd() < arg1.getBegin()) {
features.add(new Feature("arg2_arg1", true));
}
return features;
}
代码示例来源:origin: apache/ctakes
public static List<Integer> expandToNP(JCas jCas, IdentifiedAnnotation identifiedAnnotation) {
List<Integer> originalSpan = Lists.newArrayList(identifiedAnnotation.getBegin(), identifiedAnnotation.getEnd());
jCas,
TreebankNode.class,
identifiedAnnotation.getBegin(),
identifiedAnnotation.getEnd())) {
identifiedAnnotation.setBegin(sortedTreebankNodes.get(0).getBegin());
identifiedAnnotation.setEnd(sortedTreebankNodes.get(0).getEnd());
代码示例来源:origin: org.apache.ctakes/ctakes-side-effect
/** @generated
* @param jcas JCas to which this Feature Structure belongs
* @param begin offset to the begin spot in the SofA
* @param end offset to the end spot in the SofA
*/
public IdentifiedAnnotation(JCas jcas, int begin, int end) {
super(jcas);
setBegin(begin);
setEnd(end);
readObject();
}
代码示例来源:origin: apache/ctakes
annotation.setTypeID( group.getCode() );
arrIdx++;
annotation.setOntologyConceptArr( conceptArr );
extensions.addAll( resource.getModifierExtension() );
if ( FhirElementParser.hasExtension( GENERIC_EXT, extensions ) ) {
annotation.setGeneric( true );
annotation.setUncertainty( CONST.NE_UNCERTAINTY_PRESENT );
annotation.setPolarity( CONST.NE_POLARITY_NEGATION_PRESENT );
annotation.setHistoryOf( CONST.NE_HISTORY_OF_PRESENT );
annotation.setSubject( FhirElementParser.getSubjectId( resource ) );
if ( annotation instanceof EventMention ) {
final Event event = createEvent( jCas, extensions );
annotation.addToIndexes();
return annotation;
代码示例来源:origin: apache/ctakes
/**
* I2b2 wants annotation begin and end offsets plus the covered text
* @param jcas in case the blob needs to obtain annotation information from the jcas
* @param annotation -
* @return a blob with encoded text span and covered text of the annotation
*/
protected String createBlob( final JCas jcas, final IdentifiedAnnotation annotation ) {
final StringBuilder sb = new StringBuilder();
sb.append( '<' ).append( SPAN_START_LABEL ).append( '>' );
sb.append( annotation.getBegin() );
sb.append( "</" ).append( SPAN_START_LABEL ).append( '>' );
sb.append( '<' ).append( SPAN_END_LABEL ).append( '>' );
sb.append( annotation.getEnd() );
sb.append( "</" ).append( SPAN_END_LABEL ).append( '>' );
sb.append( annotation.getCoveredText() );
return sb.toString();
}
代码示例来源:origin: apache/ctakes
private static String formatRelation(BinaryTextRelation relation) {
IdentifiedAnnotation arg1 = (IdentifiedAnnotation) relation.getArg1().getArgument();
IdentifiedAnnotation arg2 = (IdentifiedAnnotation) relation.getArg2().getArgument();
String text = arg1.getCAS().getDocumentText();
int begin = Math.min(arg1.getBegin(), arg2.getBegin());
int end = Math.max(arg1.getBegin(), arg2.getBegin());
begin = Math.max(0, begin - 50);
end = Math.min(text.length(), end + 50);
return String.format(
"%s(%s(type=%d), %s(type=%d)) in ...%s...",
relation.getCategory(),
arg1.getCoveredText(),
arg1.getTypeID(),
arg2.getCoveredText(),
arg2.getTypeID(),
text.substring(begin, end).replaceAll("[\r\n]", " "));
}
代码示例来源:origin: org.apache.ctakes/ctakes-ytex-uima
@Override
public boolean filter(Annotation anno) {
if (!(anno instanceof IdentifiedAnnotation))
return false;
IdentifiedAnnotation ia = (IdentifiedAnnotation) anno;
return ia.getOntologyConceptArr() != null
&& ia.getOntologyConceptArr().size() > 0;
}
代码示例来源:origin: apache/ctakes
@Override
public void process(JCas jcas) throws AnalysisEngineProcessException {
// Create a dummy IdentifiedAnnotation in the type system
// If the BaseToken Part Of Speech is a Noun
Collection<BaseToken> tokens = JCasUtil.select(jcas, BaseToken.class);
for (BaseToken token : tokens) {
if (saveAnnotation && token.getPartOfSpeech() != null
&& token.getPartOfSpeech().startsWith("N")) {
IdentifiedAnnotation ann = new IdentifiedAnnotation(jcas);
ann.setBegin(token.getBegin());
ann.setEnd(token.getEnd());
ann.addToIndexes();
if (printAnnotation) {
LOG.info("Token:" + token.getCoveredText() + " POS:"
+ token.getPartOfSpeech());
}
}
}
}
代码示例来源:origin: apache/ctakes
static private String getAssertion( final IdentifiedAnnotation annotation ) {
final StringBuilder sb = new StringBuilder();
if ( annotation.getPolarity() == CONST.NE_POLARITY_NEGATION_PRESENT ) {
sb.append( "AFFIRMED" );
} else {
sb.append( "NEGATED" );
}
if ( annotation.getUncertainty() == CONST.NE_UNCERTAINTY_PRESENT ) {
sb.append( "UNCERTAIN" );
}
if ( annotation.getGeneric() ) {
sb.append( "GENERIC" );
}
if ( annotation.getConditional() ) {
sb.append( "CONDITIONAL" );
}
return sb.toString();
}
代码示例来源:origin: org.apache.ctakes/ctakes-assertion
eMention = new EventMention(initView, first.start, last.end);
} else {
eMention = new IdentifiedAnnotation(initView, first.start, last.end);
eMention.setTypeID(Mapper.getEntityTypeId(entityTypes.get(mentionId)));
eMention.setId(identifiedAnnotationId++);
eMention.setDiscoveryTechnique(CONST.NE_DISCOVERY_TECH_GOLD_ANNOTATION);
eMention.setConfidence(1);
eMention.addToIndexes();
内容来源于网络,如有侵权,请联系作者删除!