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

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

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

Annotation.equals介绍

暂无

代码示例

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

/**
* @param relations  relations of interest
* @param annotation identified annotation of interest
* @return all relations in the given relations where the second argument is the given annotation
*/
static public <T extends BinaryTextRelation> Collection<T> getRelationsAsSecond(
   final Collection<T> relations,
   final IdentifiedAnnotation annotation ) {
 return relations.stream()
    .filter( r -> r.getArg2().getArgument().equals( annotation ) )
    .collect( Collectors.toList() );
}

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

/**
* @param relations  relations of interest
* @param annotation identified annotation of interest
* @return all relations in the given relations where the first argument is the given annotation
*/
static public <T extends BinaryTextRelation> Collection<T> getRelationsAsFirst(
   final Collection<T> relations,
   final IdentifiedAnnotation annotation ) {
 return relations.stream()
    .filter( r -> r.getArg1().getArgument().equals( annotation ) )
    .collect( Collectors.toList() );
}

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

/**
* @param relations  relations of interest
* @param annotation identified annotation of interest
* @return all identified annotations in the given relations related to the given annotation as the first argument
*/
static public Collection<IdentifiedAnnotation> getFirstArguments(
   final Collection<? extends BinaryTextRelation> relations,
   final IdentifiedAnnotation annotation ) {
 return relations.stream()
    .filter( r -> r.getArg2().getArgument().equals( annotation ) )
    .map( r -> r.getArg1().getArgument() )
    .filter( IdentifiedAnnotation.class::isInstance )
    .map( a -> (IdentifiedAnnotation) a )
    .collect( Collectors.toList() );
}

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

/**
* @param relations  relations of interest
* @param annotation identified annotation of interest
* @return all identified annotations in the given relations related to the given annotation as the second argument
*/
static public Collection<IdentifiedAnnotation> getSecondArguments(
   final Collection<? extends BinaryTextRelation> relations,
   final IdentifiedAnnotation annotation ) {
 return relations.stream()
    .filter( r -> r.getArg1().getArgument().equals( annotation ) )
    .map( r -> r.getArg2().getArgument() )
    .filter( IdentifiedAnnotation.class::isInstance )
    .map( a -> (IdentifiedAnnotation) a )
    .collect( Collectors.toList() );
}

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

/**
 * Filter only the top level annotations (that is remove all the covered annotations).
 *
 * <p>This is not too efficient, but is should work with any ordering.
 *
 * @param <T> the generic type of the annotation
 * @param annotations the annotations to filter
 * @return a new list of containing just the top level (uncovered) annotations
 */
public static <T extends Annotation> List<T> filterToTopLevelAnnotations(
  final Collection<T> annotations) {
 final List<T> topLevel = new LinkedList<>();
 for (final T a : annotations) {
  boolean covered = false;
  for (final T b : annotations) {
   if (!a.equals(b) && b.getBegin() <= a.getBegin() && a.getEnd() <= b.getEnd()) {
    covered = true;
    break;
   }
  }
  if (!covered) {
   topLevel.add(a);
  }
 }
 return topLevel;
}

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

/**
 * Filter only the top level annotations (that is remove all the covered annotations).
 *
 * <p>This is not too efficient, but is should work with any ordering.
 *
 * @param <T> the generic type of the annotation
 * @param annotations the annotations to filter
 * @return a new list of containing just the top level (uncovered) annotations
 */
public static <T extends Annotation> List<T> filterToTopLevelAnnotations(
  final Collection<T> annotations) {
 final List<T> topLevel = new LinkedList<>();
 for (final T a : annotations) {
  boolean covered = false;
  for (final T b : annotations) {
   if (!a.equals(b) && b.getBegin() <= a.getBegin() && a.getEnd() <= b.getEnd()) {
    covered = true;
    break;
   }
  }
  if (!covered) {
   topLevel.add(a);
  }
 }
 return topLevel;
}

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

/**
* @param relation   relation of interest
* @param annotation some annotation that might be in the relation
* @return the target annotation in the relation if the first is present
*/
static private IdentifiedAnnotation getTarget( final BinaryTextRelation relation,
                       final IdentifiedAnnotation annotation ) {
 if ( !relation.getArg1()
    .getArgument()
    .equals( annotation ) ) {
   return null;
 }
 final Annotation argument = relation.getArg2()
    .getArgument();
 if ( argument != null && IdentifiedAnnotation.class.isInstance( argument ) ) {
   return (IdentifiedAnnotation) argument;
 }
 return null;
}

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

/**
* @param relation   relation of interest
* @param annotation some annotation that might be in the relation
* @return the other annotation in the relation if the first is present
*/
static private IdentifiedAnnotation getRelated( final BinaryTextRelation relation,
                        final IdentifiedAnnotation annotation ) {
 Annotation argument = null;
 if ( relation.getArg1().getArgument().equals( annotation ) ) {
   argument = relation.getArg2().getArgument();
 } else if ( relation.getArg2().getArgument().equals( annotation ) ) {
   argument = relation.getArg1().getArgument();
 }
 if ( argument != null && IdentifiedAnnotation.class.isInstance( argument ) ) {
   return (IdentifiedAnnotation) argument;
 }
 return null;
}

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

static private String getRelationText( final IdentifiedAnnotation annotation,
                   final BinaryTextRelation relation ) {
 if ( relation.getArg1().getArgument().equals( annotation ) ) {
   return SPACER + "[" + relation.getCategory() + "] " + getSafeText( relation.getArg2().getArgument() ) + NEWLINE;
 } else if ( relation.getArg2().getArgument().equals( annotation ) ) {
   return SPACER + getSafeText( relation.getArg1().getArgument() ) + " [" + relation.getCategory() + "]" + NEWLINE;
 }
 return "";
}

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

static private String getRelationText( final IdentifiedAnnotation annotation,
                   final BinaryTextRelation relation ) {
 if ( relation.getArg1()
    .getArgument()
    .equals( annotation ) ) {
   return SPACER + "[" + relation.getCategory() + "] " + getSafeText( relation.getArg2()
      .getArgument() ) + NEWLINE;
 } else if ( relation.getArg2()
    .getArgument()
    .equals( annotation ) ) {
   return SPACER + getSafeText( relation.getArg1()
      .getArgument() ) + " [" + relation.getCategory() + "]" + NEWLINE;
 }
 return "";
}

代码示例来源:origin: ch.epfl.bbp.nlp/bluima_jsre

if (coveringBr.equals(br1)) {
  matched = true;
  matchedBr1 = true;
} else if (coveringBr.equals(br2)) {
  matched = true;
  matchedBr2 = true;

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

public static boolean areAdjoining(Token t1, Token t2) {
  JCas jCas = getJCas(t1);
  FSIterator<Annotation> tokenIter = jCas.getAnnotationIndex(Token.typeIndexID).iterator();
  tokenIter.moveTo(t1);
  assert (t1.equals(tokenIter.get()));
  tokenIter.moveToNext();
  return tokenIter.isValid() && tokenIter.get().equals(t2);
}

相关文章