Package org.apache.uima.ruta.type

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


    Collection<AnnotationFS> results = new HashSet<AnnotationFS>();
    stream.moveToFirst();
    FSIterator<AnnotationFS> streamPointer = stream.copy();

    while (stream.isValid()) {
      RutaBasic anchorBasic = (RutaBasic) stream.get();
      streamPointer.moveTo(anchorBasic);

      List<RutaBasic> basicsToAdd = new ArrayList<RutaBasic>();
      basicsToAdd.add(anchorBasic);
      String text = anchorBasic.getCoveredText();
      StringBuilder candidate = new StringBuilder(text);
      String lastCandidate = candidate.toString();
      List<AnnotationFS> interResults = new ArrayList<AnnotationFS>();

      while (streamPointer.isValid()) {

        List<String> types = containsFragment(candidate.toString(), ignoreCase, ignoreLength, edit,
                distance, ignoreToken);

        if (!types.isEmpty()) {
          streamPointer.moveToNext();
          if (streamPointer.isValid()) {
            RutaBasic next = (RutaBasic) streamPointer.get();
            // List<String> contains = contains(candidate,
            // ignoreCase,
            // ignoreLength, edit, distance, ignoreToken);

            tryToCreateAnnotation(stream, results, basicsToAdd, candidate.toString(), interResults,
                    ignoreCase, ignoreLength, edit, distance, ignoreToken, typeMap);
            //
            lastCandidate = candidate.toString();
            candidate.append(next.getCoveredText());
            basicsToAdd.add(next);

          } else {
            // !streamPointer.isValid();
            tryToCreateAnnotation(stream, results, basicsToAdd, lastCandidate, interResults,
View Full Code Here


  }

  @Override
  public EvaluatedCondition eval(AnnotationFS annotation, RuleElement element,
          RutaStream stream, InferenceCrowd crowd) {
    RutaBasic beginAnchor = stream.getBeginAnchor(annotation.getBegin());
    if (!isWorkingOnList()) {
      Set<AnnotationFS> beginAnchors = beginAnchor
              .getBeginAnchors(type.getType(element.getParent()));
      boolean result = false;
      if (beginAnchors != null) {
        for (AnnotationFS annotationFS : beginAnchors) {
          result |= check(annotation, annotationFS);
          if (result == true) {
            break;
          }
        }
      }
      return new EvaluatedCondition(this, result);
    } else {
      boolean result = false;
      List<Type> types = getList().getList(element.getParent());
      for (Type type : types) {
        Set<AnnotationFS> beginAnchors = beginAnchor.getBeginAnchors(type);
        if (beginAnchors != null) {
          for (AnnotationFS annotationFS : beginAnchors) {
            result |= check(annotation, annotationFS);
            if (result == true) {
              break;
View Full Code Here

    int count = 0;
    while (count <= maxValue) {
      if (count >= minValue && it.isValid()) {
        FeatureStructure featureStructure = it.get();
        if (featureStructure instanceof RutaBasic) {
          RutaBasic each = (RutaBasic) featureStructure;
          if (each.isPartOf(type.getType(element.getParent()))) {
            return new EvaluatedCondition(this, true);
          }
        }
      }
      if (forwardValue) {
View Full Code Here

      return new EvaluatedCondition(this, result);
    }
  }

  private boolean check(RutaStream stream, AnnotationFS matched, Type givenType) {
    RutaBasic endAnchor = stream.getEndAnchor(matched.getEnd());
    return endAnchor.endsWith(givenType);
  }
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);
        }
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);
      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) {
    RutaBasic basic = anchors.get(anchor);
    if (basic != null) {
      return basic;
    } else if (anchor <= anchors.lastKey()) {
      anchor++;
      return getCeiling(anchors, 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.