Package org.apache.uima.ruta.type

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


    }
    return null;
  }

  private RutaBasic getFloor(TreeMap<Integer, RutaBasic> anchors, int anchor) {
    RutaBasic basic = anchors.get(anchor);
    if (basic != null) {
      return basic;
    } else if (anchor >= 0) {
      anchor--;
      return getFloor(anchors, anchor);
View Full Code Here


    Collection<RutaBasic> basicAnnotationsInWindow = getAllBasicsInWindow(annotation);
    for (RutaBasic basic : basicAnnotationsInWindow) {
      basic.removePartOf(type);
    }
    Type parent = type;
    RutaBasic beginAnchor = getBeginAnchor(annotation.getBegin());
    RutaBasic endAnchor = getEndAnchor(annotation.getEnd());
    beginAnchor.removeBegin(annotation, parent);
    endAnchor.removeEnd(annotation, parent);
    if (!(annotation instanceof RutaBasic)) {
      cas.removeFsFromIndexes(annotation);
    }

  }
View Full Code Here

  public Collection<RutaBasic> getAllBasicsInWindow(AnnotationFS windowAnnotation) {
    if (windowAnnotation.getBegin() >= windowAnnotation.getEnd()) {
      return Collections.emptySet();
    }
    RutaBasic beginAnchor = getBeginAnchor(windowAnnotation.getBegin());
    if (beginAnchor.getEnd() == windowAnnotation.getEnd()) {
      Collection<RutaBasic> result = new ArrayList<RutaBasic>(1);
      result.add(beginAnchor);
      return result;
    }
    // was Java 6:
    // RutaBasic endAnchor = getEndAnchor(windowAnnotation.getEnd());
    // NavigableSet<RutaBasic> subSet = basics.subSet(beginAnchor, true, endAnchor, true);

    Collection<RutaBasic> subSet = null;
    if (windowAnnotation.getEnd() == cas.getDocumentAnnotation().getEnd()
            && windowAnnotation.getBegin() == 0) {
      subSet = basics;
    } else if (windowAnnotation.getEnd() == cas.getDocumentAnnotation().getEnd()) {
      subSet = basics.tailSet(beginAnchor);
    } else {
      RutaBasic endAnchor1 = getCeiling(endAnchors, windowAnnotation.getEnd() + 1);
      if (endAnchor1 != null) {
        subSet = basics.subSet(beginAnchor, endAnchor1);
      } else {
        // hotfix for limited window stream with a window on the complete document
        subSet = new LinkedList<RutaBasic>();
        RutaBasic floor = getFloor(endAnchors, windowAnnotation.getEnd());
        Collection<RutaBasic> subSetHead = basics.subSet(beginAnchor, floor);
        RutaBasic endAnchorTail = endAnchors.get(windowAnnotation.getEnd());
        subSet.addAll(subSetHead);
        subSet.add(endAnchorTail);
      }
    }
    return subSet;
View Full Code Here

  public RutaBasic getBasicNextTo(boolean before, AnnotationFS annotation) {
    if(annotation == null) {
      return beginAnchors.get(0);
    }
    if (before) {
      RutaBasic pointer = beginAnchors.get(annotation.getBegin());
      moveTo(pointer);
      if(isVisible(pointer)) {
        moveToPrevious();
      }
      if (isValid()) {
        return (RutaBasic) get();
      }
    } else {
      RutaBasic pointer = endAnchors.get(annotation.getEnd());
      moveTo(pointer);
      if(isVisible(pointer)) {
        moveToNext();
      }
      if (isValid()) {
View Full Code Here

  public RutaBasic getNextBasic2(AnnotationFS previous) {
    AnnotationFS pointer = cas
            .createAnnotation(basicType, previous.getEnd() - 1, previous.getEnd());
    currentIt.moveTo(pointer);
    if (currentIt.isValid()) {
      RutaBasic basic = (RutaBasic) currentIt.get();
      return basic;
    }
    return null;
  }
View Full Code Here

    for (Type type : types) {
      if(type == null) {
        continue;
      }
      String name = type.getName();
      RutaBasic firstBasicOfAll = stream.getFirstBasicOfAll();
      if ("uima.tcas.DocumentAnnotation".equals(name)
              || "org.apache.uima.ruta.type.Document".equals(name)
              || (stream.getDocumentAnnotationType().getName().equals(name) && (firstBasicOfAll != null && firstBasicOfAll
                      .beginsWith(type)))) {
        // TODO what about dynamic windowing?
        result.add(stream.getDocumentAnnotation());
      } else {
        stream.moveToFirst();
        while (stream.isValid()) {
          RutaBasic nextBasic = (RutaBasic) stream.get();
          List<Type> allTypes = stream.getCas().getTypeSystem().getProperlySubsumedTypes(type);
          allTypes.add(type);
          for (Type eachType : allTypes) {
            Collection<AnnotationFS> beginAnchors = nextBasic.getBeginAnchors(eachType);
            if (beginAnchors != null) {
              for (AnnotationFS afs : beginAnchors) {
                if (afs.getEnd() <= stream.getDocumentAnnotation().getEnd()) {
                  result.add(afs);
                }
View Full Code Here

    return result;
  }

  public Collection<AnnotationFS> getAnnotationsAfter(RutaRuleElement ruleElement,
          AnnotationFS annotation, RutaStream stream, RutaBlock parent) {
    RutaBasic lastBasic = stream.getEndAnchor(annotation.getEnd());
    if (lastBasic == null) {
      return Collections.emptyList();
    }
    stream.moveTo(lastBasic);
    if(stream.isVisible(lastBasic)) {
      stream.moveToNext();
    }
    if (stream.isValid()) {
      RutaBasic nextBasic = (RutaBasic) stream.get();
      List<Type> reTypes = getTypes(parent, stream);
      Collection<AnnotationFS> anchors = new TreeSet<AnnotationFS>(comparator);
      for (Type eachMatchType : reTypes) {
        List<Type> types = stream.getCas().getTypeSystem().getProperlySubsumedTypes(eachMatchType);
        types.add(eachMatchType);
        for (Type eachType : types) {
          Collection<AnnotationFS> beginAnchors = nextBasic.getBeginAnchors(eachType);
          if (beginAnchors != null) {
            for (AnnotationFS afs : beginAnchors) {
              if (afs.getEnd() <= stream.getDocumentAnnotation().getEnd()) {
                anchors.add(afs);
              }
View Full Code Here

    return Collections.emptyList();
  }

  public Collection<AnnotationFS> getAnnotationsBefore(RutaRuleElement ruleElement,
          AnnotationFS annotation, RutaStream stream, RutaBlock parent) {
    RutaBasic firstBasic = stream.getBeginAnchor(annotation.getBegin());
    if (firstBasic == null) {
      return Collections.emptyList();
    }
    stream.moveTo(firstBasic);
    if(stream.isVisible(firstBasic)) {
      stream.moveToPrevious();
    }
    if (stream.isValid()) {
      RutaBasic nextBasic = (RutaBasic) stream.get();
      List<Type> reTypes = getTypes(parent, stream);
      Collection<AnnotationFS> anchors = new TreeSet<AnnotationFS>(comparator);
      for (Type eachMatchType : reTypes) {
        List<Type> types = stream.getCas().getTypeSystem().getProperlySubsumedTypes(eachMatchType);
        types.add(eachMatchType);
        for (Type eachType : types) {
          Collection<AnnotationFS> endAnchors = nextBasic.getEndAnchors(eachType);
          if (endAnchors != null) {
            for (AnnotationFS afs : endAnchors) {
              if (afs.getBegin() >= stream.getDocumentAnnotation().getBegin()) {
                anchors.add(afs);
              }
View Full Code Here

    constraint.add(type);
  }

  public boolean match(FeatureStructure fs) {
    if (fs instanceof RutaBasic) {
      RutaBasic tmb = (RutaBasic) fs;
      if(tmb.getBeginMap().isEmpty() && tmb.getEndMap().isEmpty()) {
        return true;
      }
    }
    if(constraint.match(fs)) {
        return true;
    }
    boolean result = false;
    if (fs instanceof RutaBasic) {
      RutaBasic tmb = (RutaBasic) fs;
      if (types != null) {
        for (Type each : types) {
          result |= tmb.isPartOf(each)|| tmb.beginsWith(each) || tmb.endsWith(each);
          if (result)
            break;
        }
      }
    }
View Full Code Here

          char[] ignoreToken, int maxIgnoredTokens, boolean ignoreWS) {
    List<AnnotationFS> result = new ArrayList<AnnotationFS>();
    for (String each : list) {
      stream.moveToFirst();
      while (stream.hasNext()) {
        RutaBasic next = (RutaBasic) stream.next();
        if (each.equals(next.getCoveredText())) {
          result.add(next);
        }
      }
    }
    return result;
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.