Package org.apache.uima.ruta.type

Examples of org.apache.uima.ruta.type.RutaBasic


  @Override
  public EvaluatedCondition eval(AnnotationFS annotation, RuleElement element,
          RutaStream stream, InferenceCrowd crowd) {
    Type t = type.getType(element.getParent());

    RutaBasic beginAnchor = stream.getBeginAnchor(annotation.getBegin());
    RutaBasic endAnchor = stream.getEndAnchor(annotation.getEnd());
    if (beginAnchor == null || endAnchor == null || !beginAnchor.isPartOf(t)
            || !endAnchor.isPartOf(t)) {
      return new EvaluatedCondition(this, false);
    }

    boolean relatively = relative == null ? true : relative.getBooleanValue(element.getParent());
View Full Code Here


          RutaStream stream, InferenceCrowd crowd) {
    Type contextType = type.getType(element.getParent());
    stream.moveToFirst();
    List<AnnotationFS> visibleContexts = new ArrayList<AnnotationFS>();
    while (stream.isValid()) {
      RutaBasic each = (RutaBasic) stream.get();
      if (each.beginsWith(contextType)) {
        visibleContexts.addAll(each.getBeginAnchors(contextType));
      }
      stream.moveToNext();
    }
    List<AnnotationFS> overlappingContexts = new ArrayList<AnnotationFS>();
    for (AnnotationFS eachContext : visibleContexts) {
      if (eachContext.getBegin() <= annotation.getBegin()
              && eachContext.getEnd() >= annotation.getEnd()) {
        overlappingContexts.add(eachContext);
      }
    }

    boolean result = false;
    for (AnnotationFS eachContext : overlappingContexts) {
      int index = 0;
      int counter = 0;
      List<RutaBasic> basicsInWindow = stream.getBasicsInWindow(eachContext);
      for (RutaBasic eachBasic : basicsInWindow) {
        Set<AnnotationFS> beginAnchors = eachBasic.getBeginAnchors(annotation.getType());
        if (beginAnchors != null) {
          for (AnnotationFS each : beginAnchors) {
            counter++;
            if (each.getBegin() == annotation.getBegin()
                    && each.getEnd() == annotation.getEnd()
                    && (each.getType().equals(annotation.getType()) || stream.getCas()
                            .getTypeSystem().subsumes(annotation.getType(), each.getType()))) {
              index = counter;
            }
          }
        }
      }
View Full Code Here

  }

  @Override
  public EvaluatedCondition eval(AnnotationFS annotation, RuleElement element,
          RutaStream stream, InferenceCrowd crowd) {
    RutaBasic endAnchor = stream.getEndAnchor(annotation.getEnd());
    Type t = type.getType(element.getParent());
    boolean result = endAnchor.beginsWith(t) && endAnchor.endsWith(t);
    return new EvaluatedCondition(this, result);
  }
View Full Code Here

    List<AnnotationFS> matchedAnnotations = match.getMatchedAnnotations(stream, indexes,
            element.getContainer());
    for (AnnotationFS matched : matchedAnnotations) {

      if (TYPES_AT_BEGIN.equals(op)) {
        RutaBasic beginAnchor = stream.getBeginAnchor(matched.getBegin());
        Collection<Set<AnnotationFS>> values = beginAnchor.getBeginMap().values();
        Set<AnnotationFS> aset = new HashSet<AnnotationFS>();
        for (Set<AnnotationFS> set : values) {
          aset.addAll(set);
        }
        for (AnnotationFS annotationFS : aset) {
          list.add(annotationFS.getType());
        }
      } else if (TYPES_AT_END.equals(op)) {
        RutaBasic endAnchor = stream.getEndAnchor(matched.getEnd());
        Collection<Set<AnnotationFS>> values = endAnchor.getEndMap().values();
        Set<AnnotationFS> aset = new HashSet<AnnotationFS>();
        for (Set<AnnotationFS> set : values) {
          aset.addAll(set);
        }
        for (AnnotationFS annotationFS : aset) {
View Full Code Here

      List<Type> list = typeList.getList(element.getParent());
      for (Type type : list) {
        Map<RutaBasic, Collection<AnnotationFS>> map = new HashMap<RutaBasic, Collection<AnnotationFS>>();
        AnnotationIndex<AnnotationFS> ai = cas.getAnnotationIndex(type);
        for (AnnotationFS fs : ai) {
          RutaBasic basic = stream.getFirstBasicInWindow(fs);
          if (basic != null) {
            Collection<AnnotationFS> collection = map.get(basic);
            if (collection == null) {
              collection = new HashSet<AnnotationFS>();
              map.put(basic, collection);
View Full Code Here

    List<List<RuleElementMatch>> matchInfo = match.getMatchInfo(element);
    for (List<RuleElementMatch> l : matchInfo) {
      RuleElementMatch ruleElementMatch = l.get(0);
      List<AnnotationFS> textsMatched = ruleElementMatch.getTextsMatched();
      for (AnnotationFS each : textsMatched) {
        RutaBasic beginAnchor = stream.getBeginAnchor(each.getBegin());
        Set<AnnotationFS> beginAnchors = beginAnchor.getBeginAnchors(t);
        for (AnnotationFS annotationFS : beginAnchors) {
          if (annotationFS.getEnd() == each.getEnd()
                  && !retainType(annotationFS.getType(), retainList, typeSystem)) {
            toRemove.add(annotationFS);
          }
View Full Code Here

    }
    List<Integer> indexList = getIndexList(element, list);
    List<AnnotationFS> matchedAnnotations = match.getMatchedAnnotations(stream, indexList,
            element.getContainer());
    for (AnnotationFS annotationFS : matchedAnnotations) {
      RutaBasic beginAnchor = stream.getBeginAnchor(annotationFS.getBegin());
      Set<AnnotationFS> beginAnchors = beginAnchor.getBeginAnchors(t);
      if (beginAnchors != null) {
        for (AnnotationFS each : new ArrayList<AnnotationFS>(beginAnchors)) {
          if (allAtAnchor || each.getEnd() == annotationFS.getEnd()) {
            stream.removeAnnotation(each, t);
          }
View Full Code Here

  private boolean check(AnnotationFS annotation, Type t, RutaStream stream) {
    if (annotation == null) {
      return false;
    }
    RutaBasic beginAnchor = stream.getBeginAnchor(annotation.getBegin());
    return beginAnchor.beginsWith(t);
  }
View Full Code Here

    List<AnnotationFS> matchedAnnotations = match.getMatchedAnnotations(stream, null,
            element.getContainer());
    for (AnnotationFS matchedAnnotation : matchedAnnotations) {
      List<RutaBasic> list = stream.getBasicsInWindow(matchedAnnotation);
      if (!list.isEmpty()) {
        RutaBasic last = list.get(list.size() - 1);
        createAnnotation(last, element, stream, match);
      }

    }
View Full Code Here

  }

  private boolean check(AnnotationFS annotation, RutaStream stream, Type t) {
    stream.moveTo(annotation);
    while (stream.isValid()) {
      RutaBasic each = (RutaBasic) stream.get();
      Set<AnnotationFS> set = each.getBeginAnchors(t);
      if(set == null)  {
        stream.moveToPrevious();
        continue;
      }
      for (AnnotationFS afs : set) {
View Full Code Here

TOP

Related Classes of org.apache.uima.ruta.type.RutaBasic

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.