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

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

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

IdentifiedAnnotation.getUncertainty介绍

[英]getter for uncertainty - gets
[中]不确定性的getter-get

代码示例

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

public static boolean isUncertain(IdentifiedAnnotation mention){
 return mention.getUncertainty() == CONST.NE_UNCERTAINTY_PRESENT;
}

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

public static boolean isUncertain(IdentifiedAnnotation mention){
 return mention.getUncertainty() == CONST.NE_UNCERTAINTY_PRESENT;
}

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

/**
* @param annotation -
* @return polarity for a single annotation
*/
static private String createPolarity( final IdentifiedAnnotation annotation ) {
 if ( annotation instanceof TimeMention || annotation instanceof EntityMention ) {
   return GENERIC;
 }
 if ( annotation.getPolarity() < 0 ) {
   if ( annotation.getUncertainty() > 0 ) {
    return UNCERTAIN_NEGATED;
   } else {
    return NEGATED;
   }
 } else if ( annotation.getUncertainty() > 0 ) {
   return UNCERTAIN;
 } else {
   return AFFIRMED;
 }
}

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

/**
* @param annotation -
* @return polarity for a single annotation
*/
static private String createPolarity( final IdentifiedAnnotation annotation ) {
 if ( annotation instanceof TimeMention || annotation instanceof EntityMention ) {
   return GENERIC;
 }
 if ( annotation.getPolarity() < 0 ) {
   if ( annotation.getUncertainty() > 0 ) {
    return UNCERTAIN_NEGATED;
   } else {
    return NEGATED;
   }
 } else if ( annotation.getUncertainty() > 0 ) {
   return UNCERTAIN;
 } else {
   return AFFIRMED;
 }
}

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

static private Collection<String> createPolarity( final IdentifiedAnnotation annotation ) {
 final Collection<String> tags = new ArrayList<>();
 if ( annotation.getPolarity() < 0 ) {
   if ( annotation.getUncertainty() > 0 ) {
    tags.add( "uncertainnegated" );
   } else {
    tags.add( "negated" );
   }
 } else if ( annotation.getUncertainty() > 0 ) {
   tags.add( "uncertain" );
 } else {
   tags.add( "affirmed" );
 }
 return tags;
}

代码示例来源: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: 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-assertion

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

private void printContext(String text, IdentifiedAnnotation mention, int radius) {
    int mentionBegin = mention.getBegin();
    int mentionEnd   = mention.getEnd();
    StringBuilder sb = new StringBuilder();
    
    int snipBegin;
    int snipEnd;
    snipBegin = (mentionBegin-radius<0)?             0               : mentionBegin-radius;
    snipEnd   = (mentionEnd+radius>text.length()-1)? text.length()-1 : mentionEnd+radius;

    String[] tmp = mention.getClass().getName().split("\\.");
    String semGroup = tmp[tmp.length-1];

    sb.append(text.substring(snipBegin, mentionBegin));
    sb.append("[[["+mention.getCoveredText()+"]]]");
    sb.append(text.substring(mentionEnd, snipEnd));
//        sb.toString().replaceAll("\\n", "\\n| ");
    System.out.println("| "+ sb.toString().replaceAll("\\n", "\n| "));
    
    System.out.println(": "+ semGroup + 
        " : beg=" + mention.getBegin() + " : end=" + mention.getEnd() +
        " : c=" + mention.getConditional()  + " : g=" + mention.getGeneric() +
        " : h=" + mention.getHistoryOf() + " : p="  + mention.getPolarity() + 
        " : s=" + mention.getSubject() + " : u="  + mention.getUncertainty());
  }

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

private void printContext(String text, IdentifiedAnnotation mention, int radius) {
    int mentionBegin = mention.getBegin();
    int mentionEnd   = mention.getEnd();
    StringBuilder sb = new StringBuilder();
    
    int snipBegin;
    int snipEnd;
    snipBegin = (mentionBegin-radius<0)?             0               : mentionBegin-radius;
    snipEnd   = (mentionEnd+radius>text.length()-1)? text.length()-1 : mentionEnd+radius;

    String[] tmp = mention.getClass().getName().split("\\.");
    String semGroup = tmp[tmp.length-1];

    sb.append(text.substring(snipBegin, mentionBegin));
    sb.append("[[["+mention.getCoveredText()+"]]]");
    sb.append(text.substring(mentionEnd, snipEnd));
//        sb.toString().replaceAll("\\n", "\\n| ");
    System.out.println("| "+ sb.toString().replaceAll("\\n", "\n| "));
    
    System.out.println(": "+ semGroup + 
        " : beg=" + mention.getBegin() + " : end=" + mention.getEnd() +
        " : c=" + mention.getConditional()  + " : g=" + mention.getGeneric() +
        " : h=" + mention.getHistoryOf() + " : p="  + mention.getPolarity() + 
        " : s=" + mention.getSubject() + " : u="  + mention.getUncertainty());
  }

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

/**
* @param annotation -
* @return a line of text with doctimerel, modality, aspect and permanence ; if available
*/
static private String getAnnotationProperties( final IdentifiedAnnotation annotation ) {
 final StringBuilder sb = new StringBuilder();
 if ( annotation.getPolarity() < 0 ) {
   sb.append( " negated" );
 }
 if ( annotation.getUncertainty() == 1 ) {
   sb.append( " uncertain" );
 }
 if ( annotation.getGeneric() ) {
   sb.append( " generic" );
 }
 if ( annotation.getConditional() ) {
   sb.append( " conditional" );
 }
 if ( annotation.getHistoryOf() == 1 ) {
   sb.append( " in history" );
 }
 if ( annotation.getSubject() != null && !annotation.getSubject().isEmpty() ) {
   sb.append( " for " ).append( annotation.getSubject() );
 }
 return sb.toString();
}

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

/**
* @param annotation -
* @return a line of text with doctimerel, modality, aspect and permanence ; if available
*/
static private String getAnnotationProperties( final IdentifiedAnnotation annotation ) {
 final StringBuilder sb = new StringBuilder();
 if ( annotation.getPolarity() < 0 ) {
   sb.append( " negated" );
 }
 if ( annotation.getUncertainty() == 1 ) {
   sb.append( " uncertain" );
 }
 if ( annotation.getGeneric() ) {
   sb.append( " generic" );
 }
 if ( annotation.getConditional() ) {
   sb.append( " conditional" );
 }
 if ( annotation.getHistoryOf() == 1 ) {
   sb.append( " in history" );
 }
 if ( annotation.getSubject() != null && !annotation.getSubject().isEmpty() ) {
   sb.append( " for " ).append( annotation.getSubject() );
 }
 return sb.toString();
}

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

@Override
public void setClassLabel( IdentifiedAnnotation entityOrEventMention, Instance<String> instance )
   throws AnalysisEngineProcessException {
 if ( this.isTraining() ) {
   String uncertainty = (entityOrEventMention.getUncertainty() == CONST.NE_UNCERTAINTY_PRESENT) ? "uncertain"
                                                 : "certain";
   // downsampling. initialize probabilityOfKeepingADefaultExample to 1.0 for no downsampling
   if ( "certain".equals( uncertainty )
     && coin.nextDouble() >= this.probabilityOfKeepingADefaultExample ) {
    return;
   }
   instance.setOutcome( uncertainty );
 } else {
   String label = this.classifier.classify( instance.getFeatures() );
   int uncertainty = 0;
   if ( label != null && label.equals( "uncertain" ) ) {
    uncertainty = CONST.NE_UNCERTAINTY_PRESENT;
   } else if ( label != null && label.equals( "certain" ) ) {
    uncertainty = CONST.NE_UNCERTAINTY_ABSENT;
   }
   entityOrEventMention.setUncertainty( uncertainty );
 }
}

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

@Override
public void setClassLabel(IdentifiedAnnotation entityOrEventMention, Instance<String> instance) throws AnalysisEngineProcessException {
  if (this.isTraining())
   {
    String uncertainty = (entityOrEventMention.getUncertainty() == CONST.NE_UNCERTAINTY_PRESENT) ? "uncertain" : "certain";
    // downsampling. initialize probabilityOfKeepingADefaultExample to 1.0 for no downsampling
    if ("certain".equals(uncertainty) 
        && coin.nextDouble() >= this.probabilityOfKeepingADefaultExample) {
      return;
    }
    instance.setOutcome(uncertainty);
   } else
   {
    String label = this.classifier.classify(instance.getFeatures());
    int uncertainty = 0;
    if (label!= null && label.equals("uncertain"))
    {
     uncertainty = CONST.NE_UNCERTAINTY_PRESENT;
    } else if (label != null && label.equals("certain"))
    {
     uncertainty = CONST.NE_UNCERTAINTY_ABSENT;
    }
    entityOrEventMention.setUncertainty(uncertainty);
   }
}

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

@Override
public void setClassLabel(IdentifiedAnnotation entityOrEventMention, Instance<String> instance) throws AnalysisEngineProcessException {
  if (this.isTraining())
   {
    String uncertainty = (entityOrEventMention.getUncertainty() == CONST.NE_UNCERTAINTY_PRESENT) ? "uncertain" : "certain";
    // downsampling. initialize probabilityOfKeepingADefaultExample to 1.0 for no downsampling
    if ("certain".equals(uncertainty) 
        && coin.nextDouble() >= this.probabilityOfKeepingADefaultExample) {
      return;
    }
    instance.setOutcome(uncertainty);
   } else
   {
    String label = this.classifier.classify(instance.getFeatures());
    int uncertainty = 0;
    if (label!= null && label.equals("uncertain"))
    {
     uncertainty = CONST.NE_UNCERTAINTY_PRESENT;
    } else if (label != null && label.equals("certain"))
    {
     uncertainty = CONST.NE_UNCERTAINTY_ABSENT;
    }
    entityOrEventMention.setUncertainty(uncertainty);
   }
}

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

break;
case UNCERTAINTY:
  m.setUncertainty(mention.getUncertainty());
  break;

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

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: 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();
  
}

相关文章

微信公众号

最新文章

更多