org.apache.uima.jcas.tcas.Annotation.setEnd()方法的使用及代码示例

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

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

Annotation.setEnd介绍

暂无

代码示例

代码示例来源:origin: apache/uima-uimaj

/**
 * Constructor with begin and end passed as arguments
 * @param jcas JCas
 * @param begin begin offset
 * @param end   end offset
 */
public Annotation(JCas jcas, int begin, int end) {
 this(jcas); // forward to constructor
 this.setBegin(begin);
 this.setEnd(end);
}

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

private void modifyEnd(Annotation ann, Annotation aAnnot,
    Annotation bAnnot) {
  switch (iv_endSrc) {
  case END_A:
    ann.setEnd(aAnnot.getEnd());
    break;
  case END_B:
    ann.setEnd(bAnnot.getEnd());
    break;
  case END_SMALLEST:
    ann.setEnd(Math.min(aAnnot.getEnd(), bAnnot.getEnd()));
    break;
  case END_LARGEST:
    ann.setEnd(Math.max(aAnnot.getEnd(), bAnnot.getEnd()));
    break;
  }
}

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

private void modifyEnd(Annotation ann, Annotation aAnnot,
    Annotation bAnnot) {
  switch (iv_endSrc) {
  case END_A:
    ann.setEnd(aAnnot.getEnd());
    break;
  case END_B:
    ann.setEnd(bAnnot.getEnd());
    break;
  case END_SMALLEST:
    ann.setEnd(Math.min(aAnnot.getEnd(), bAnnot.getEnd()));
    break;
  case END_LARGEST:
    ann.setEnd(Math.max(aAnnot.getEnd(), bAnnot.getEnd()));
    break;
  }
}

代码示例来源:origin: CLLKazan/UIMA-Ext

private static void postprocess(int spanBegin, Annotation anno, int begin, int end) {
    anno.setBegin(spanBegin + begin);
    anno.setEnd(spanBegin + end);
    anno.addToIndexes();
  }
}

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

private void trim(Annotation aAnnotation)
  {
    StringBuilder buffer = getBuffer();
    int s = aAnnotation.getBegin();
    int e = aAnnotation.getEnd();
    while (Character.isWhitespace(buffer.charAt(s))) {
      s++;
    }
    while ((e > s + 1) && Character.isWhitespace(buffer.charAt(e - 1))) {
      e--;
    }
    aAnnotation.setBegin(s);
    aAnnotation.setEnd(e);
  }
}

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

private void trim(Annotation aAnnotation)
  {
    StringBuilder buffer = getBuffer();
    int s = aAnnotation.getBegin();
    int e = aAnnotation.getEnd();
    while (Character.isWhitespace(buffer.charAt(s))) {
      s++;
    }
    while ((e > s + 1) && Character.isWhitespace(buffer.charAt(e - 1))) {
      e--;
    }
    aAnnotation.setBegin(s);
    aAnnotation.setEnd(e);
  }
}

代码示例来源:origin: uk.gov.dstl.baleen/baleen-uima

/**
 * Sets the begin and end of the annotation against the document (rather than this block)
 *
 * @param <T> the generic type
 * @param annotation the annotation
 * @param begin the begin offset within this text block
 * @param end the end offset within this text block
 * @return the annotaiton (with begin and end set to the document offsets)
 */
public <T extends Annotation> T setBeginAndEnd(
  final T annotation, final int begin, final int end) {
 annotation.setBegin(toDocumentOffset(begin));
 annotation.setEnd(toDocumentOffset(end));
 return annotation;
}

代码示例来源:origin: ClearTK/cleartk

@Override
public Annotation convert(JCas view, TopTreebankNode topNode) {
 Annotation annotation = new Annotation(view);
 List<Annotation> subAnnotations = new ArrayList<Annotation>();
 for (PropbankRelation rel : this.relations) {
  subAnnotations.add(rel.convert(view, topNode));
 }
 // annotation.setAnnotations(UIMAUtil.toFSArray(view, subAnnotations));
 int[] span = AnnotationUtil.getAnnotationsExtent(subAnnotations);
 annotation.setBegin(span[0]);
 annotation.setEnd(span[1]);
 annotation.addToIndexes();
 return annotation;
}

代码示例来源:origin: org.cleartk/cleartk-corpus

@Override
public Annotation convert(JCas view, TopTreebankNode topNode) {
 Annotation annotation = new Annotation(view);
 List<Annotation> subAnnotations = new ArrayList<Annotation>();
 for (PropbankRelation rel : this.relations) {
  subAnnotations.add(rel.convert(view, topNode));
 }
 // annotation.setAnnotations(UIMAUtil.toFSArray(view, subAnnotations));
 int[] span = AnnotationUtil.getAnnotationsExtent(subAnnotations);
 annotation.setBegin(span[0]);
 annotation.setEnd(span[1]);
 annotation.addToIndexes();
 return annotation;
}

代码示例来源:origin: dstl/baleen

/**
 * Sets the begin and end of the annotation against the document (rather than this block)
 *
 * @param <T> the generic type
 * @param annotation the annotation
 * @param begin the begin offset within this text block
 * @param end the end offset within this text block
 * @return the annotaiton (with begin and end set to the document offsets)
 */
public <T extends Annotation> T setBeginAndEnd(
  final T annotation, final int begin, final int end) {
 annotation.setBegin(toDocumentOffset(begin));
 annotation.setEnd(toDocumentOffset(end));
 return annotation;
}

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

default void addTextSpan( final T type, final Basic resource, final Logger logger ) {
 final Pair<Integer> textSpan = FhirElementParser.getTextSpan( resource.getExtension() );
 if ( textSpan == null ) {
   logger.error( "Could not parse text span for basic " + resource.getId() );
   return;
 }
 type.setBegin( textSpan.getValue1() );
 type.setEnd( textSpan.getValue2() );
}

代码示例来源:origin: dstl/baleen

@Override
 public void process(JCas aJCas) throws AnalysisEngineProcessException {
  // Do nothing
  Pattern p = Pattern.compile("\\d+");
  Matcher m = p.matcher(aJCas.getDocumentText());
  while (m.find()) {
   Annotation a = new Annotation(aJCas);
   a.setBegin(m.start());
   a.setEnd(m.end());

   a.addToIndexes();
  }
 }
}

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

/**
 * Trim the offsets of the given annotation to remove leading/trailing whitespace.
 * <p>
 * <b>Note:</b> use this method if the document text of the CAS has not been set yet but you
 * have it available in a buffer.
 * <p>
 * <b>Note:</b> best use this method before adding the annotation to the indexes.
 * 
 * @param aText
 *            the document text (available so far).
 * @param aAnnotation
 *            the annotation to trim. Offsets are updated.
 */
public static void trim(CharSequence aText, Annotation aAnnotation)
{
  int[] offsets = { aAnnotation.getBegin(), aAnnotation.getEnd() };
  trim(aText, offsets);
  aAnnotation.setBegin(offsets[0]);
  aAnnotation.setEnd(offsets[1]);
}

代码示例来源:origin: ClearTK/cleartk

private static void testAnnotationType(JCas jcas, Annotation annotation) throws Exception {
 Class<?> annotationClass = annotation.getClass();
 Constructor<?> constructor = annotationClass.getConstructor(JCas.class);
 annotation = (Annotation) constructor.newInstance(jcas);
 Assert.assertEquals(0, annotation.getBegin());
 Assert.assertEquals(0, annotation.getEnd());
 annotation.setBegin(15);
 Assert.assertEquals(15, annotation.getBegin());
 annotation.setEnd(12);
 Assert.assertEquals(12, annotation.getEnd());
 constructor = annotationClass.getConstructor(JCas.class, int.class, int.class);
 annotation = (Annotation) constructor.newInstance(jcas, 4, 6);
 Assert.assertEquals(4, annotation.getBegin());
 Assert.assertEquals(6, annotation.getEnd());
}

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

public void changeOffsets(AnnotationFS annotation, int begin, int end,
    AbstractRuleMatch<? extends AbstractRule> modifikator) {
 if (!(annotation instanceof Annotation)) {
  return;
 }
 Annotation a = (Annotation) annotation;
 if (annotation.getBegin() == begin && annotation.getEnd() == end) {
  return;
 }
 // TODO implement incremental reindexing
 removeAnnotation(a);
 a.setBegin(begin);
 a.setEnd(end);
 addAnnotation(a, true, modifikator);
}

代码示例来源:origin: de.unistuttgart.ims/uimautil

protected <T extends TOP> T getFeatureStructure(JCas jcas, XMLElement hAnno, Element elm, Rule<T> mapping) {
  T annotation = null;
  if (mapping.isUnique()) {
    annotation = getOrCreate(jcas, mapping.getTargetClass());
  } else {
    annotation = (T) jcas.getCas().createFS(JCasUtil.getType(jcas, mapping.getTargetClass()));
    jcas.getCas().addFsToIndexes(annotation);
    if (Annotation.class.isAssignableFrom(mapping.getTargetClass())) {
      ((Annotation) annotation).setBegin(hAnno.getBegin());
      ((Annotation) annotation).setEnd(hAnno.getEnd());
    }
    if (elm.hasAttr("xml:id") && !exists(elm.attr("xml:id"))) {
      String id = elm.attr("xml:id");
      idRegistry.put(id, new AbstractMap.SimpleEntry<Element, FeatureStructure>(elm, annotation));
    }
  }
  return annotation;
}

代码示例来源:origin: de.unistuttgart.ims.uima.io/generic-xml-reader

protected <T extends TOP> T getFeatureStructure(JCas jcas, XMLElement hAnno, Element elm, Rule<T> mapping) {
  T annotation = null;
  if (mapping.isUnique()) {
    annotation = getOrCreate(jcas, mapping.getTargetClass());
  } else {
    annotation = jcas.getCas().createFS(JCasUtil.getType(jcas, mapping.getTargetClass()));
    jcas.getCas().addFsToIndexes(annotation);
    if (Annotation.class.isAssignableFrom(mapping.getTargetClass())) {
      ((Annotation) annotation).setBegin(hAnno.getBegin());
      ((Annotation) annotation).setEnd(hAnno.getEnd());
    }
    if (elm.hasAttr("xml:id") && !exists(elm.attr("xml:id"))) {
      String id = elm.attr("xml:id");
      idRegistry.put(id, new AbstractMap.SimpleEntry<Element, FeatureStructure>(elm, annotation));
    }
  }
  return annotation;
}

代码示例来源:origin: dstl/baleen

private void addAnnotation(final int start, final int end) {
 final Annotation a = new WordToken(jCas);
 a.setBegin(start);
 a.setEnd(end);
 a.addToIndexes();
}

代码示例来源:origin: dstl/baleen

@Test
public void testGetSingleCoveredMissing() {
 final Annotation a = new Annotation(jCas);
 a.setBegin(1);
 a.setEnd(12);
 final Optional<Annotation> missing = AnnotationUtils.getSingleCovered(Annotation.class, a);
 Assert.assertFalse(missing.isPresent());
}

代码示例来源:origin: dstl/baleen

@Test
public void testGetSingleCovered() {
 final Annotation a = new Annotation(jCas);
 a.setBegin(0);
 a.setEnd(4);
 final Optional<Annotation> single = AnnotationUtils.getSingleCovered(Annotation.class, a);
 Assert.assertEquals("012", single.get().getCoveredText());
}

相关文章