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

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

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

IdentifiedAnnotation.getEnd介绍

暂无

代码示例

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

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

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

static private Collection<IdentifiedAnnotation> getEndAnnotations( final Collection<IdentifiedAnnotation> annotations,
                                 final int adjustedEnd ) {
 if ( annotations == null || annotations.isEmpty() ) {
   return Collections.emptyList();
 }
 return annotations.stream()
    .filter( a -> a.getEnd() == adjustedEnd )
    .collect( Collectors.toSet() );
}

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

static private Collection<IdentifiedAnnotation> getEndAnnotations( final Collection<IdentifiedAnnotation> annotations,
                                 final int adjustedEnd ) {
 if ( annotations == null || annotations.isEmpty() ) {
   return Collections.emptyList();
 }
 return annotations.stream()
    .filter( a -> a.getEnd() == adjustedEnd )
    .collect( Collectors.toSet() );
}

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

/**
* 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

/**
* 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: 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

@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: org.apache.ctakes/ctakes-coreference

public static int sentDist(JCas jcas, IdentifiedAnnotation arg1,
  IdentifiedAnnotation arg2){
 return JCasUtil.selectCovered(jcas, Sentence.class, arg1.getBegin(), arg2.getEnd()).size();
}

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

public static int sentDist(JCas jcas, IdentifiedAnnotation arg1,
  IdentifiedAnnotation arg2){
 return JCasUtil.selectCovered(jcas, Sentence.class, arg1.getBegin(), arg2.getEnd()).size();
}

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

private static String formatError(JCas jcas, IdentifiedAnnotation mention){
  List<Sentence> context = JCasUtil.selectCovering(jcas, Sentence.class, mention.getBegin(), mention.getEnd());
  StringBuffer buff = new StringBuffer();
  if(context.size() > 0){
    Sentence sent = context.get(0);
    buff.append(sent.getCoveredText());
    long offset = mention.getBegin() - sent.getBegin();
    if (offset>=Integer.MAX_VALUE || offset<=Integer.MIN_VALUE) { offset=0; } // for spanless annots
    buff.insert((int)offset, "***");
    offset += (mention.getEnd()-mention.getBegin() + 3);
    buff.insert((int)offset, "***");
  }
  return buff.toString();
}

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

@Override
public List<Feature> extract(JCas jCas, IdentifiedAnnotation arg1,
    IdentifiedAnnotation arg2) throws AnalysisEngineProcessException {
  List<Feature> feats = new ArrayList<>();
  feats.add(new Feature("TOK_DIST",
       JCasUtil.selectCovered(jCas, BaseToken.class, arg1.getBegin(), arg2.getEnd()).size() / (double)CorefConsts.TOKDIST));
  feats.add(new Feature("SENT_DIST",
      JCasUtil.selectCovered(jCas, Sentence.class, arg1.getBegin(), arg2.getEnd()).size() / (double) CorefConsts.NEDIST));
  return feats;
}

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

@Override
public List<Feature> extract(JCas jCas, IdentifiedAnnotation arg1,
    IdentifiedAnnotation arg2) throws AnalysisEngineProcessException {
  List<Feature> feats = new ArrayList<>();
  feats.add(new Feature("TOK_DIST",
       JCasUtil.selectCovered(jCas, BaseToken.class, arg1.getBegin(), arg2.getEnd()).size() / (double)CorefConsts.TOKDIST));
  feats.add(new Feature("SENT_DIST",
      JCasUtil.selectCovered(jCas, Sentence.class, arg1.getBegin(), arg2.getEnd()).size() / (double) CorefConsts.NEDIST));
  return feats;
}

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

private static String formatError(JCas jcas, IdentifiedAnnotation mention){
  List<Sentence> context = JCasUtil.selectCovering(jcas, Sentence.class, mention.getBegin(), mention.getEnd());
  StringBuffer buff = new StringBuffer();
  if(context.size() > 0){
    Sentence sent = context.get(0);
    buff.append(sent.getCoveredText());
    long offset = mention.getBegin() - sent.getBegin();
    if (offset>=Integer.MAX_VALUE || offset<=Integer.MIN_VALUE) { offset=0; } // for spanless annots
    buff.insert((int)offset, "***");
    offset += (mention.getEnd()-mention.getBegin() + 3);
    buff.insert((int)offset, "***");
  }
  return buff.toString();
}

代码示例来源: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>();
 features.addAll(this.mention1FeaturesExtractor.extract(jCas, arg1));
 features.addAll(this.mention2FeaturesExtractor.extract(jCas, arg2));
 features.addAll(this.nEntityMentionsBetween.extract(jCas, arg1, arg2));
 // entity type of both mentions, concatenated
 int type1 = arg1.getTypeID();
 int type2 = arg2.getTypeID();
 features.add(new Feature("type1type2", String.format("%s_%s", type1, type2)));
 // is mention1 included in mention2?
 boolean begins1After2 = arg1.getBegin() >= arg2.getBegin();
 boolean ends1Before2 = arg1.getEnd() <= arg2.getEnd();
 features.add(new Feature("mention1InMention2", begins1After2 && ends1Before2));
 // is mention2 included in mention1?
 boolean begins2After1 = arg2.getBegin() >= arg1.getBegin();
 boolean ends2Before1 = arg2.getEnd() <= arg1.getEnd();
 features.add(new Feature("mention2InMention1", begins2After1 && ends2Before1));
 return features;
}

代码示例来源: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()) {
    for(PunctuationToken token : JCasUtil.selectCovered(jCas, PunctuationToken.class, arg1.getEnd(), arg2.getBegin())) {
      features.add(new Feature("arg1_punctuation_arg2", token.getCoveredText()));
      break;
    }
  }
  
  // entity2 ... entity1 scenario
  if(arg2.getEnd() < arg1.getBegin()) {
    for(PunctuationToken token : JCasUtil.selectCovered(jCas, PunctuationToken.class, arg2.getEnd(), arg1.getBegin())) {
      features.add(new Feature("arg2_punctuation_arg1", token.getCoveredText()));
      break;
    }
  }
  
 return features;
}

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

/**
 * Return the List of drug IdentifiedAnnotation within the span
 * @param jcas
 * @param begin
 * @param end
 * @return
 */
public static List getDrugsInSpan(JCas jcas, int begin, int end) {
  JFSIndexRepository indexes = jcas.getJFSIndexRepository();
  Iterator neItr= indexes.getAnnotationIndex(IdentifiedAnnotation.type).iterator();
  List l = new ArrayList();
  
  //add drug to List
  while (neItr.hasNext()) {
    IdentifiedAnnotation nea = (IdentifiedAnnotation) neItr.next();            
    if(nea.getTypeID()==1)
      if(nea.getBegin()>=begin && nea.getEnd()<=end)
        l.add(nea);
  } 
  
  return l;
}

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

/**
 * Is this pair of entities enclosed inside a noun phrase?
 */
public static boolean isEnclosed(IdentifiedAnnotationPair pair, TreebankNode np) {
 
 IdentifiedAnnotation arg1 = pair.getArg1();
 IdentifiedAnnotation arg2 = pair.getArg2();
 if((np.getBegin() <= arg1.getBegin()) &&
   (np.getEnd() >= arg1.getEnd()) &&
   (np.getBegin() <= arg2.getBegin()) &&
   (np.getEnd() >= arg2.getEnd())) {
  return true;
 }
 
 return false;
}

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

/**
 * Is this pair of entities enclosed inside a noun phrase?
 */
public static boolean isEnclosed(IdentifiedAnnotationPair pair, TreebankNode np) {
 
 IdentifiedAnnotation arg1 = pair.getArg1();
 IdentifiedAnnotation arg2 = pair.getArg2();
 if((np.getBegin() <= arg1.getBegin()) &&
   (np.getEnd() >= arg1.getEnd()) &&
   (np.getBegin() <= arg2.getBegin()) &&
   (np.getEnd() >= arg2.getEnd())) {
  return true;
 }
 
 return false;
}

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

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

相关文章

微信公众号

最新文章

更多