org.apache.uima.cas.text.AnnotationFS.getEnd()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(123)

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

AnnotationFS.getEnd介绍

[英]Get the end position of the annotation as character offset into the text. The end position points at the first character after the annotation, such that (getEnd()-getBegin()) == getCoveredText().length().
[中]获取注释的结束位置作为文本中的字符偏移量。结束位置指向注释后的第一个字符,例如(getEnd()-getBegin()) == getCoveredText().length()

代码示例

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

private boolean isContaining(AnnotationFS annotation, AnnotationFS containing) {
 return (containing.getBegin() <= annotation.getBegin())
  && (containing.getEnd() >= annotation.getEnd());
}

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

private void addChunkAnnotation(CAS tcas, AnnotationFS[] tokenAnnotations,
                String tag, int start, int end) {
 AnnotationFS chunk = tcas.createAnnotation(mChunkType,
   tokenAnnotations[start].getBegin(), tokenAnnotations[end - 1].getEnd());
 chunk.setStringValue(mChunkFeature, tag);
 tcas.getIndexRepository().addFS(chunk);
}

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

public AnnotationIteratorPair next() {
 if (!this.upperIt.hasNext()) {
  throw new NoSuchElementException();
 }
 final AnnotationFS upperFS = this.upperIt.next();
 this.upperBegin = upperFS.getBegin();
 this.upperEnd = upperFS.getEnd();
 this.nextLowerChecked = false;
 return new AnnotationIteratorPair(upperFS, new AnnotationIterator());
}

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

public boolean hasNext() {
 if (AnnotationComboIterator.this.nextLowerChecked) {
  return AnnotationComboIterator.this.nextLowerAvailable;
 }
 AnnotationComboIterator.this.nextLowerChecked = true;
 AnnotationComboIterator.this.nextLowerAvailable = false;
 if (AnnotationComboIterator.this.lowerIt.isValid()) {
  AnnotationFS lowerFS = AnnotationComboIterator.this.lowerIt.get();
  int lowerBegin = lowerFS.getBegin();
  while (lowerBegin < AnnotationComboIterator.this.upperBegin) {
   AnnotationComboIterator.this.lowerIt.moveToNext();
   if (AnnotationComboIterator.this.lowerIt.isValid()) {
    lowerFS = AnnotationComboIterator.this.lowerIt.get();
    lowerBegin = lowerFS.getBegin();
   } else {
    return false;
   }
  }
  if (AnnotationComboIterator.this.upperEnd >= lowerFS.getEnd()) {
   AnnotationComboIterator.this.nextLowerAvailable = true;
  }
 }
 return AnnotationComboIterator.this.nextLowerAvailable;
}

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

protected void process(CAS cas, AnnotationFS sentenceAnnotation) {
 FSIndex<AnnotationFS> allTokens = cas.getAnnotationIndex(mTokenType);
 ContainingConstraint containingConstraint =
   new ContainingConstraint(sentenceAnnotation);
 String sentence = sentenceAnnotation.getCoveredText();
 Iterator<AnnotationFS> containingTokens = cas.createFilteredIterator(
   allTokens.iterator(), containingConstraint);
 List<Span> tokenSpans = new LinkedList<>();
 while (containingTokens.hasNext()) {
  AnnotationFS token = containingTokens.next();
  tokenSpans.add(new Span(token.getBegin() - sentenceAnnotation.getBegin(),
    token.getEnd() - sentenceAnnotation.getBegin()));
 }
 ParseConverter converter = new ParseConverter(sentence, tokenSpans.toArray(new Span[tokenSpans.size()]));
 Parse unparsedTree = converter.getParseForTagger();
 if (unparsedTree.getChildCount() > 0) {
  Parse parse = mParser.parse(unparsedTree);
  // TODO: We need a strategy to handle the case that a full
  //       parse could not be found. What to do in this case?
  parse = converter.transformParseFromTagger(parse);
  if (mLogger.isLoggable(Level.INFO)) {
   StringBuffer parseString = new StringBuffer();
   parse.show(parseString);
   mLogger.log(Level.INFO, parseString.toString());
  }
  createAnnotation(cas, sentenceAnnotation.getBegin(), parse);
 }
}

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

names[i].getStart()).getBegin();
names[i].getEnd() - 1).getEnd();

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

/**
 * Create a new combo iterator.
 *
 * @param cas
 *          The CAS we're operating on.
 * @param upper
 *          The type of the upper iterator, e.g., sentence.
 * @param lower
 *          The type of the lower iterator, e.g., token.
 */
public AnnotationComboIterator(CAS cas, Type upper, Type lower) {
 this.upperIt = cas.getAnnotationIndex(upper).iterator();
 this.lowerIt = cas.getAnnotationIndex(lower).iterator();
 this.upperIt.moveToFirst();
 this.lowerIt.moveToFirst();
 if (this.upperIt.isValid()) {
  final AnnotationFS upperFS = this.upperIt.get();
  this.upperBegin = upperFS.getBegin();
  this.upperEnd = upperFS.getEnd();
 } else {
  this.nextLowerChecked = true;
 }
}

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

/**
* @param annotation     -
* @param sentenceOffset begin span offset of the containing sentence
*/
public DefaultTextSpan( final AnnotationFS annotation, final int sentenceOffset ) {
 this( annotation.getBegin() - sentenceOffset, annotation.getEnd() - sentenceOffset );
}

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

private int getNextPointer(boolean after, AnnotationFS anchor) {
 if (after) {
  return anchor.getEnd();
 } else {
  return anchor.getBegin();
 }
}

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

private boolean check(AnnotationFS a1, AnnotationFS a2) {
 boolean result = false;
 if (a1 != null && a2 != null && a1.getBegin() == a2.getBegin() && a1.getEnd() == a2.getEnd()) {
  result = true;
 }
 return result;
}

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

private boolean check(AnnotationFS a1, AnnotationFS a2) {
 boolean result = false;
 if (a1 != null && a2 != null && a1.getBegin() == a2.getBegin() && a1.getEnd() == a2.getEnd()) {
  result = true;
 }
 return result;
}

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/de.tudarmstadt.ukp.clarin.webanno.brat

@Override
  public int compare(AnnotationFS arg0, AnnotationFS arg1)
  {
    int beginDiff = arg0.getBegin() - arg1.getBegin();
    if (beginDiff == 0) {
      return arg1.getEnd() - arg0.getEnd();
    }
    else {
      return beginDiff;
    }
  }
}

代码示例来源:origin: webanno/webanno

@Override
  public int compare(AnnotationFS arg0, AnnotationFS arg1)
  {
    int beginDiff = arg0.getBegin() - arg1.getBegin();
    if (beginDiff == 0) {
      return arg1.getEnd() - arg0.getEnd();
    }
    else {
      return beginDiff;
    }
  }
}

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/webanno-api-annotation

@Override
  public int compare(AnnotationFS arg0, AnnotationFS arg1)
  {
    int beginDiff = arg0.getBegin() - arg1.getBegin();
    if (beginDiff == 0) {
      return arg1.getEnd() - arg0.getEnd();
    }
    else {
      return beginDiff;
    }
  }
}

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/webanno-io-tsv

private boolean isMultiToken(AnnotationFS aFs)
{
  for (AnnotationUnit unit : units) {
    if (unit.begin <= aFs.getBegin() && unit.end > aFs.getBegin()
        && unit.end < aFs.getEnd()) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/webanno-tsv

private boolean isMultiToken(AnnotationFS aFs) {
  for (AnnotationUnit unit : units) {
    if (unit.begin <= aFs.getBegin() && unit.end > aFs.getBegin() && unit.end < aFs.getEnd()) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.stopwordremover-asl

@Override
  public int compare(AnnotationFS aO1, AnnotationFS aO2)
  {
    if (aO1.getBegin() == aO2.getBegin()) {
      return aO1.getEnd() - aO2.getEnd();
    }
    else {
      return aO1.getBegin() - aO2.getBegin();
    }
  }
}

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/webanno-api-annotation

public static List<AnnotationFS> selectAt(CAS aJcas, final Type type, int aBegin, int aEnd)
{
  List<AnnotationFS> covered = CasUtil.selectCovered(aJcas, type, aBegin, aEnd);
  // Remove all that do not have the exact same offset
  covered.removeIf(cur -> !(cur.getBegin() == aBegin && cur.getEnd() == aEnd));
  return covered;
}

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/webanno-constraints

public static List<AnnotationFS> selectAt(CAS aJcas, final Type type, int aBegin, int aEnd)
{
  List<AnnotationFS> covered = CasUtil.selectCovered(aJcas, type, aBegin, aEnd);
  // Remove all that do not have the exact same offset
  covered.removeIf(cur -> !(cur.getBegin() == aBegin && cur.getEnd() == aEnd));
  return covered;
}

代码示例来源:origin: webanno/webanno

public static List<AnnotationFS> selectAt(CAS aJcas, final Type type, int aBegin, int aEnd)
{
  List<AnnotationFS> covered = CasUtil.selectCovered(aJcas, type, aBegin, aEnd);
  // Remove all that do not have the exact same offset
  covered.removeIf(cur -> !(cur.getBegin() == aBegin && cur.getEnd() == aEnd));
  return covered;
}

相关文章