Package org.apache.uima.ruta.type

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


    }
    List<String> tokens = new ArrayList<String>();
    FSIterator<org.apache.uima.jcas.tcas.Annotation> iterator = cas.getAnnotationIndex(
            RutaBasic.type).iterator();
    while (iterator.isValid()) {
      RutaBasic each = (RutaBasic) iterator.get();
      String replace = each.getReplacement() == null ? each.getCoveredText() : each
              .getReplacement();
      Type type = getColorType(each, coloredTypes, cas);
      if (type != null && !"".equals(replace)) {
        StyleMapEntry entry = styleMap.get(type.getName());
        String backgroundColor = "#"
View Full Code Here


    int oldBegin = annotation.getBegin();
    int oldEnd = annotation.getEnd();
    int newBegin = oldBegin;
    int newEnd = oldEnd;

    RutaBasic beginBasic = stream.getBeginAnchor(oldBegin);
    while (isPartof(beginBasic, typesToTrim) && beginBasic.getBegin() < oldEnd) {
      beginBasic = stream.getBasicNextTo(false, beginBasic);
    }
    newBegin = beginBasic.getBegin();

    RutaBasic endBasic = stream.getEndAnchor(oldEnd);
    while (isPartof(endBasic, typesToTrim) && endBasic.getEnd() > newBegin) {
      endBasic = stream.getBasicNextTo(true, endBasic);
    }
    newEnd = endBasic.getEnd();

    if (oldBegin != newBegin || newEnd != oldEnd) {
      stream.removeAnnotation(annotation);
      if (annotation instanceof Annotation) {
        Annotation a = (Annotation) annotation;
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

    beginAnchors = new TreeMap<Integer, RutaBasic>();
    endAnchors = new TreeMap<Integer, RutaBasic>();
    FSIterator<AnnotationFS> iterator = cas.getAnnotationIndex(basicType).subiterator(
            documentAnnotation);
    while (iterator.isValid()) {
      RutaBasic e = (RutaBasic) iterator.get();
      beginAnchors.put(e.getBegin(), e);
      endAnchors.put(e.getEnd(), e);
      basics.add(e);
      iterator.moveToNext();
    }

  }
View Full Code Here

      if (anchors.size() == 1) {
        // for Java 6:
        // Integer first = anchors.pollFirst();
        Integer first = anchors.first();
        anchors.remove(first);
        RutaBasic newTMB = new RutaBasic(getJCas(), first, first);
        newTMB.setLowMemoryProfile(lowMemoryProfile);
        beginAnchors.put(first, newTMB);
        endAnchors.put(first, newTMB);
        basics.add(newTMB);
        cas.addFsToIndexes(newTMB);
      } else {
        while (anchors.size() >= 2) {
          // for Java 6:
          // Integer first = anchors.pollFirst();
          Integer first = anchors.first();
          anchors.remove(first);
          Integer second = anchors.first();
          RutaBasic newTMB = new RutaBasic(getJCas(), first, second);
          newTMB.setLowMemoryProfile(lowMemoryProfile);
          beginAnchors.put(first, newTMB);
          endAnchors.put(second, newTMB);
          basics.add(newTMB);
          cas.addFsToIndexes(newTMB);
        }
      }
    } else {
      RutaBasic firstBasic = (RutaBasic) basicIndex.iterator().get();
      if(firstBasic.isLowMemoryProfile() != lowMemoryProfile) {
        for (AnnotationFS each : basicIndex) {
          RutaBasic eachBasic = (RutaBasic) each;
          eachBasic.setLowMemoryProfile(lowMemoryProfile);
        }
      }
    }
    for (AnnotationFS a : allAnnotations) {
      if (!a.getType().equals(basicType)) {
View Full Code Here

    Type type = annotation.getType();
    boolean modified = checkSpan(annotation);
    if (modified && updateInternal) {
      updateIterators(filter.getWindowAnnotation());
    }
    RutaBasic beginAnchor = getBeginAnchor(annotation.getBegin());
    RutaBasic endAnchor = getEndAnchor(annotation.getEnd());
    beginAnchor.addBegin(annotation, type);
    if (endAnchor != null) {
      endAnchor.addEnd(annotation, type);
    }
    Collection<RutaBasic> basicAnnotationsInWindow = getAllBasicsInWindow(annotation);
    for (RutaBasic basic : basicAnnotationsInWindow) {
      basic.addPartOf(type);
    }
View Full Code Here

  private boolean checkSpan(AnnotationFS annotation) {
    boolean result = false;
    int begin = annotation.getBegin();
    int end = annotation.getEnd();
    RutaBasic beginAnchor = getBeginAnchor(begin);
    RutaBasic endAnchor = getEndAnchor(end);
    if (beginAnchor != null && endAnchor != null) {
      result = false;
    } else {
      if (beginAnchor == null) {
        result |= checkAnchor(begin);
View Full Code Here

    // Entry<Integer, RutaBasic> floorEntry = endAnchors.floorEntry(anchor);
    // Entry<Integer, RutaBasic> ceilingEntry = endAnchors.ceilingEntry(anchor);
    // if (floorEntry != null && ceilingEntry != null) {
    // RutaBasic floor = floorEntry.getValue();
    // RutaBasic ceiling = ceilingEntry.getValue();
    RutaBasic floor = getFloor(endAnchors, anchor);
    if (floor == null) {
      floor = getFloor(beginAnchors, anchor);
    }
    RutaBasic ceiling = getCeiling(endAnchors, anchor);
    if (floor != null && ceiling != null) {
      RutaBasic toSplit = null;
      if (floor.getEnd() > anchor) {
        toSplit = floor;
      } else {
        toSplit = ceiling;
      }
      int newEnd = toSplit.getEnd();
      cas.removeFsFromIndexes(toSplit);
      toSplit.setEnd(anchor);
      RutaBasic newTMB = new RutaBasic(getJCas(), anchor, newEnd);
      newTMB.setLowMemoryProfile(lowMemoryProfile);
      cas.addFsToIndexes(toSplit);
      cas.addFsToIndexes(newTMB);
      beginAnchors.put(floor.getBegin(), floor);
      beginAnchors.put(newTMB.getBegin(), newTMB);
      beginAnchors.put(ceiling.getBegin(), ceiling);
      endAnchors.put(floor.getEnd(), floor);
      endAnchors.put(newTMB.getEnd(), newTMB);
      endAnchors.put(ceiling.getEnd(), ceiling);
      return true;
    } else {
      // TODO this should never happen! test it!
    }
View Full Code Here

    return false;
  }

  private RutaBasic getCeiling(TreeMap<Integer, RutaBasic> anchors, int anchor) {
    while(anchor <= anchors.lastKey()) {
      RutaBasic basic = anchors.get(anchor);
      if (basic != null) {
        return basic;
      }
      anchor++;
    }
View Full Code Here

    return null;
  }

  private RutaBasic getFloor(TreeMap<Integer, RutaBasic> anchors, int anchor) {
    while(anchor >= 0) {
      RutaBasic basic = anchors.get(anchor);
      if (basic != null) {
        return basic;
      }
      anchor--;
    }
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.