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

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

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

Annotation.<init>介绍

[英]Constructor with begin and end passed as arguments
[中]以begin和end作为参数传递的构造函数

代码示例

代码示例来源:origin: de.julielab/jcore-lingpipe-gazetteer-ae

public static <T extends Annotation> List<T> getAnnotations(JCas jCas, int begin, int end, Class<T> cls) {
  Annotation annotation = new Annotation(jCas, begin, end);
  return getAnnotations(jCas, annotation, cls);
}

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

static private Annotation createAnnotation( final JCas jCas, final String className ) {
 try {
   final Class<?> clazz = Class.forName( className );
   if ( Annotation.class.isAssignableFrom( clazz ) ) {
    final Constructor<?> constructor = clazz.getConstructor( JCas.class );
    return (Annotation) constructor.newInstance( jCas );
   } else {
    LOGGER.error( "Cannot create a ctakes annotation for class " + className );
   }
 } catch ( ClassNotFoundException | NoSuchMethodException
    | InstantiationException
    | IllegalAccessException
    | InvocationTargetException multE ) {
   LOGGER.error( "Cannot determine ctakes annotation type for class " + className );
 }
 return new Annotation( jCas );
}

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

private void tryToCreateAnnotation(TextMarkerStream stream, boolean ignoreCase, int size,
    ArrayList<AnnotationFS> results, List<TextMarkerBasic> basicsToAdd, String lastCandidate,
    Annotation interResult, char[] ignoreChars, int maxIgnoredChars, boolean ignoreWS) {
 if (basicsToAdd.size() >= 1
     && contains(lastCandidate, ignoreCase, size, ignoreChars, maxIgnoredChars, ignoreWS)) {
  results.add(new Annotation(stream.getJCas(), basicsToAdd.get(0).getBegin(), basicsToAdd.get(
      basicsToAdd.size() - 1).getEnd()));
 } else if (interResult != null) {
  results.add(interResult);
 }
}

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

private void tryToCreateAnnotation(RutaStream stream, boolean ignoreCase, int size,
    ArrayList<AnnotationFS> results, List<RutaBasic> basicsToAdd, String lastCandidate,
    Annotation interResult, char[] ignoreChars, int maxIgnoredChars, boolean ignoreWS) {
 if (basicsToAdd.size() >= 1
     && contains(lastCandidate, ignoreCase, size, ignoreChars, maxIgnoredChars, ignoreWS)) {
  results.add(new Annotation(stream.getJCas(), basicsToAdd.get(0).getBegin(), basicsToAdd.get(
      basicsToAdd.size() - 1).getEnd()));
 } else if (interResult != null) {
  results.add(interResult);
 }
}

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

@Override
 public Type getType() {
  return new Annotation(jCas).getType();
 }
}

代码示例来源: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: 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: hltfbk/Excitement-Open-Platform

private Annotation getAnnotationObject(JCas aJCas, String viewName, String type, Integer[] index) throws Exception{
  
  if (type.matches(txpAnn.token))
    return new Token(aJCas.getView(viewName));
  if (type.matches(txpAnn.lemma))
    return new Lemma(aJCas.getView(viewName));
  if (type.matches(txpAnn.pos))
    return getAnnotationObject(aJCas, viewName, txpAnn.getAnnotation(type).get(index), POS.class);
  if (type.matches(txpAnn.sentence))
    return new Sentence(aJCas.getView(viewName));
  if (type.matches(txpAnn.ne))
    return getAnnotationObject(aJCas, viewName, txpAnn.getNEtype(index), NamedEntity.class);
  
  return new Annotation(aJCas.getView(viewName));
}

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

/**
 * For correct behavior, requires types to be listed in TypePriorities so that the subiterator works as expected
 */
public static FSIterator getAnnotationsIteratorInSpan(JCas jcas, int type, int beginSpan, int endSpan)
{
  Annotation ann = new Annotation(jcas, beginSpan, endSpan);
  ann.addToIndexes();
  AnnotationIndex<?> annIdx = jcas.getAnnotationIndex(type);
  FSIterator<?> itr = annIdx.subiterator(ann);
  ann.removeFromIndexes();
  return itr;
}

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

/**
 * returns the number of annotations of specified type in the 
 */
public static int countAnnotationsInSpan(JCas jcas, int type, int beginSpan, int endSpan)
{
  Annotation ann = new Annotation(jcas, beginSpan, endSpan);
  ann.addToIndexes();
  AnnotationIndex<?> annIdx = jcas.getAnnotationIndex(type);
  ann.removeFromIndexes();
  return annIdx.size();
}

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

public List<Feature> extractBetween(JCas view, FOCUS_T annotation1, FOCUS_T annotation2)
  throws CleartkExtractorException {
 int begin = annotation1.getEnd();
 int end = annotation2.getBegin();
 // FIXME: creating a new annotation may leak memory - is there a better approach?
 Annotation focusAnnotation = new Annotation(view, begin, end);
 return this.extract(view, focusAnnotation, new NoBounds());
}

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

/**
 * For correct behavior, requires types to be listed in TypePriorities so that the subiterator works as expected
 */
public static FSIterator getAnnotationsIteratorInSpan(JCas jcas, int type, int beginSpan, int endSpan)
{
  Annotation ann = new Annotation(jcas, beginSpan, endSpan);
  ann.addToIndexes();
  AnnotationIndex<?> annIdx = jcas.getAnnotationIndex(type);
  FSIterator<?> itr = annIdx.subiterator(ann);
  ann.removeFromIndexes();
  return itr;
}

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

/**
 * returns the number of annotations of specified type in the 
 */
public static int countAnnotationsInSpan(JCas jcas, int type, int beginSpan, int endSpan)
{
  Annotation ann = new Annotation(jcas, beginSpan, endSpan);
  ann.addToIndexes();
  AnnotationIndex<?> annIdx = jcas.getAnnotationIndex(type);
  ann.removeFromIndexes();
  return annIdx.size();
}

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

@Before
public void setUp() throws UIMAException {
 jCas = JCasSingleton.getJCasInstance();
 annotation = new Annotation(jCas);
 context = UimaContextFactory.createUimaContext(PipelineBuilder.PIPELINE_NAME, PIPELINE_NAME);
}

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

@Before
public void setUp() throws UIMAException {
 jCas = JCasSingleton.getJCasInstance();
 annotation = new Annotation(jCas);
 context = UimaContextFactory.createUimaContext(PipelineBuilder.PIPELINE_NAME, PIPELINE_NAME);
}

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

@Before
public void setUp() throws UIMAException {
 jCas = JCasSingleton.getJCasInstance();
 annotation = new Annotation(jCas);
 specifier = new CustomResourceSpecifier_impl();
}

代码示例来源: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());
}

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

@Test
public void testRecordable() throws UIMAException {
 JCas jCas = JCasFactory.createJCas();
 FakeRecordable fakeRecordable = new FakeRecordable(jCas);
 assertEquals(new Annotation(jCas).getType().getName(), fakeRecordable.getTypeName());
}

相关文章