org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation.setPolarity()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(11.8k)|赞(0)|评价(0)|浏览(60)

本文整理了Java中org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation.setPolarity()方法的一些代码示例,展示了IdentifiedAnnotation.setPolarity()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IdentifiedAnnotation.setPolarity()方法的具体详情如下:
包路径:org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation
类名称:IdentifiedAnnotation
方法名:setPolarity

IdentifiedAnnotation.setPolarity介绍

[英]setter for polarity - sets
[中]极性设置器

代码示例

代码示例来源:origin: org.apache.ctakes/ctakes-ne-contexts

public void consumeHit(JCas jcas, Annotation focusAnnot, int scope, ContextHit ctxHit)
      throws AnalysisEngineProcessException {
    if (focusAnnot instanceof IdentifiedAnnotation) {
      IdentifiedAnnotation neAnnot = (IdentifiedAnnotation) focusAnnot;
      neAnnot.setPolarity(-1);
    }

    createContextAnnot(jcas, focusAnnot, scope, ctxHit).addToIndexes();
  }
}

代码示例来源:origin: apache/ctakes

public void consumeHit(JCas jcas, Annotation focusAnnot, int scope, ContextHit ctxHit)
      throws AnalysisEngineProcessException {
    if (focusAnnot instanceof IdentifiedAnnotation) {
      IdentifiedAnnotation neAnnot = (IdentifiedAnnotation) focusAnnot;
      neAnnot.setPolarity(-1);
    }

    createContextAnnot(jcas, focusAnnot, scope, ctxHit).addToIndexes();
  }
}

代码示例来源:origin: org.apache.ctakes/ctakes-assertion

private void checkForAttrValue(IdentifiedAnnotation eMention, String role,
    String value) {
  if (role.contains("_normalization")) {
     if (role.startsWith("conditional")) {
       eMention.setConditional(Boolean.valueOf(value));
     } else if (role.startsWith("generic")) {
       eMention.setGeneric(Boolean.valueOf(value));
     } else if (role.startsWith("negation_indicator")) {
       // assumes that the string from Knowtator is exactly "negation_present"
       if (value.equals("negation_present")) { 
         eMention.setPolarity(CONST.NE_POLARITY_NEGATION_PRESENT);
       } else {
         eMention.setPolarity(CONST.NE_POLARITY_NEGATION_ABSENT);
       }
     } else if (role.startsWith("subject")) {
       // assumes that the strings from Knowtator are exactly what's in the type system
       eMention.setSubject(value);
     } else if (role.startsWith("uncertainty_indicator")) {
       // assumes that the string from Knowtator is exactly "indicator_present"
       if (value.equals("indicator_present")) { 
         eMention.setUncertainty(CONST.NE_UNCERTAINTY_PRESENT);
       } else {
         eMention.setUncertainty(CONST.NE_UNCERTAINTY_ABSENT);
       }
     } else if (role.startsWith("generic")) {
       eMention.setGeneric(Boolean.valueOf(value));
     }
   }
}

代码示例来源:origin: apache/ctakes

private void checkForAttrValue(IdentifiedAnnotation eMention, String role,
    String value) {
  if (role.contains("_normalization")) {
     if (role.startsWith("conditional")) {
       eMention.setConditional(Boolean.valueOf(value));
     } else if (role.startsWith("generic")) {
       eMention.setGeneric(Boolean.valueOf(value));
     } else if (role.startsWith("negation_indicator")) {
       // assumes that the string from Knowtator is exactly "negation_present"
       if (value.equals("negation_present")) { 
         eMention.setPolarity(CONST.NE_POLARITY_NEGATION_PRESENT);
       } else {
         eMention.setPolarity(CONST.NE_POLARITY_NEGATION_ABSENT);
       }
     } else if (role.startsWith("subject")) {
       // assumes that the strings from Knowtator are exactly what's in the type system
       eMention.setSubject(value);
     } else if (role.startsWith("uncertainty_indicator")) {
       // assumes that the string from Knowtator is exactly "indicator_present"
       if (value.equals("indicator_present")) { 
         eMention.setUncertainty(CONST.NE_UNCERTAINTY_PRESENT);
       } else {
         eMention.setUncertainty(CONST.NE_UNCERTAINTY_ABSENT);
       }
     } else if (role.startsWith("generic")) {
       eMention.setGeneric(Boolean.valueOf(value));
     }
   }
}

代码示例来源:origin: org.apache.ctakes/ctakes-core

static private void processNegatables( final String docText, final Iterable<ListEntry> listEntries,
                   final java.util.List<IdentifiedAnnotation> negatables ) {
 int j = 0;
 IdentifiedAnnotation negatable = negatables.get( 0 );
 for ( ListEntry listEntry : listEntries ) {
   final int entryBegin = listEntry.getBegin();
   // find next negatable in a listEntry
   while ( negatable.getEnd() < entryBegin ) {
    j++;
    if ( j >= negatables.size() ) {
      return;
    }
    negatable = negatables.get( j );
   }
   final int entryEnd = listEntry.getEnd();
   // process all negatables in the current listEntry
   while ( negatable.getBegin() >= entryBegin && negatable.getEnd() < entryEnd ) {
    final String window = docText.substring( negatable.getEnd(), entryEnd );
    final Matcher matcher = NEGATIVE_PATTERN.matcher( window );
    if ( matcher.find() ) {
      negatable.setPolarity( CONST.NE_POLARITY_NEGATION_PRESENT );
    }
    j++;
    if ( j >= negatables.size() ) {
      return;
    }
    negatable = negatables.get( j );
   }
 }
}

代码示例来源:origin: apache/ctakes

static private void processNegatables( final String docText, final Iterable<ListEntry> listEntries,
                   final java.util.List<IdentifiedAnnotation> negatables ) {
 int j = 0;
 IdentifiedAnnotation negatable = negatables.get( 0 );
 for ( ListEntry listEntry : listEntries ) {
   final int entryBegin = listEntry.getBegin();
   // find next negatable in a listEntry
   while ( negatable.getEnd() < entryBegin ) {
    j++;
    if ( j >= negatables.size() ) {
      return;
    }
    negatable = negatables.get( j );
   }
   final int entryEnd = listEntry.getEnd();
   // process all negatables in the current listEntry
   while ( negatable.getBegin() >= entryBegin && negatable.getEnd() < entryEnd ) {
    final String window = docText.substring( negatable.getEnd(), entryEnd );
    final Matcher matcher = NEGATIVE_PATTERN.matcher( window );
    if ( matcher.find() ) {
      negatable.setPolarity( CONST.NE_POLARITY_NEGATION_PRESENT );
    }
    j++;
    if ( j >= negatables.size() ) {
      return;
    }
    negatable = negatables.get( j );
   }
 }
}

代码示例来源:origin: apache/ctakes

.getEnd(), entityOrEventMention.getClass().getName() ) );
entityOrEventMention.setPolarity( polarity );

代码示例来源:origin: org.apache.ctakes/ctakes-assertion

logger.debug(String.format("DECODING/EVAL: %s//%s [%d-%d] (%s)", label, polarity, entityOrEventMention.getBegin(), entityOrEventMention.getEnd(), entityOrEventMention.getClass().getName()));
entityOrEventMention.setPolarity(polarity);

代码示例来源:origin: org.apache.ctakes/ctakes-assertion

logger.debug(String.format("DECODING/EVAL: %s//%s [%d-%d] (%s)", label, polarity, entityOrEventMention.getBegin(), entityOrEventMention.getEnd(), entityOrEventMention.getClass().getName()));
entityOrEventMention.setPolarity(polarity);

代码示例来源:origin: apache/ctakes

logger.debug(String.format("DECODING/EVAL: %s//%s [%d-%d] (%s)", label, polarity, entityOrEventMention.getBegin(), entityOrEventMention.getEnd(), entityOrEventMention.getClass().getName()));
entityOrEventMention.setPolarity(polarity);

代码示例来源:origin: apache/ctakes

logger.debug(String.format("DECODING/EVAL: %s//%s [%d-%d] (%s)", label, polarity, entityOrEventMention.getBegin(), entityOrEventMention.getEnd(), entityOrEventMention.getClass().getName()));
entityOrEventMention.setPolarity(polarity);

代码示例来源: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: apache/ctakes

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-assertion

static private void fillProperties( final IdentifiedAnnotation annotation,
                  final int polarity, final int uncertainty,
                  final boolean generic, final boolean conditional,
                  final String subject, final float confidence ) {
 annotation.setPolarity( polarity );
 annotation.setUncertainty( uncertainty );
 annotation.setGeneric( generic );
 annotation.setConditional( conditional );
 annotation.setSubject( subject );
 annotation.setConfidence( confidence );
}

代码示例来源:origin: apache/ctakes

static private void fillProperties( final IdentifiedAnnotation annotation,
                  final int polarity, final int uncertainty,
                  final boolean generic, final boolean conditional,
                  final String subject, final float confidence ) {
 annotation.setPolarity( polarity );
 annotation.setUncertainty( uncertainty );
 annotation.setGeneric( generic );
 annotation.setConditional( conditional );
 annotation.setSubject( subject );
 annotation.setConfidence( confidence );
}

代码示例来源:origin: org.apache.ctakes/ctakes-assertion

break;
case POLARITY:
  m.setPolarity(mention.getPolarity());
  break;
case SUBJECT:

代码示例来源:origin: apache/ctakes

break;
case POLARITY:
  m.setPolarity(mention.getPolarity());
  break;
case SUBJECT:

代码示例来源:origin: apache/ctakes

ne.setConfidence(-1);
  if (negated || (this.negatePossibilities && possible))
    ne.setPolarity(-1);
} else {
  ne.setPolarity(negated || possible ? -1 : 0);
  float confidence = negated ? -1 : 1;
  if (possible)

代码示例来源: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: apache/ctakes

/**
 * 
 * @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();
  
}

相关文章

微信公众号

最新文章

更多