Package org.apache.uima.ruta.type

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


      List<Type> list = typeList.getList(element.getParent(), stream);
      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());
        Collection<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

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

    RutaBasic beginBasic = stream.getBeginAnchor(oldBegin);
    while (beginBasic != null && isPartof(beginBasic, typesToTrim)
            && beginBasic.getBegin() < oldEnd) {
      beginBasic = stream.getBasicNextTo(false, beginBasic);
    }
    if (beginBasic != null) {
      newBegin = beginBasic.getBegin();
    } else {
      stream.removeAnnotation(annotation);
      return;
    }

    RutaBasic endBasic = stream.getEndAnchor(oldEnd);
    while (endBasic != null && isPartof(endBasic, typesToTrim) && endBasic.getEnd() > newBegin) {
      endBasic = stream.getBasicNextTo(true, endBasic);
    }
    if (endBasic != null) {
      newEnd = endBasic.getEnd();
    } else {
      stream.removeAnnotation(annotation);
      return;
    }
View Full Code Here

          char[] ignoreChars, int maxIgnoredChars, boolean ignoreWS) {
    ArrayList<AnnotationFS> results = new ArrayList<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();
      Annotation interResult = null;
      while (streamPointer.isValid()) {
        if (containsFragment(candidate.toString(), ignoreCase, size, ignoreChars, maxIgnoredChars,
                ignoreWS)) {
          streamPointer.moveToNext();
          if (streamPointer.isValid()) {
            RutaBasic next = (RutaBasic) streamPointer.get();
            if (contains(candidate.toString(), ignoreCase, size, ignoreChars, maxIgnoredChars,
                    ignoreWS)) {
              interResult = new Annotation(stream.getJCas(), basicsToAdd.get(0).getBegin(),
                      basicsToAdd.get(basicsToAdd.size() - 1).getEnd());
            }
            // lastCandidate = candidate.toString();
            candidate.append(next.getCoveredText());
            basicsToAdd.add(next);
          } else {
            tryToCreateAnnotation(stream, ignoreCase, size, results, basicsToAdd,
                    candidate.toString(), interResult, ignoreChars, maxIgnoredChars, ignoreWS);
          }
View Full Code Here

          RutaRuleElement sideStepOrigin, RutaStream stream, InferenceCrowd crowd) {
    AnnotationFS nextOne = annotation;
    boolean doneHere = false;
    while (!doneHere
            && (nextOne = getNextPositionForComposed(cre, after, nextOne, stream)) != null) {
      RutaBasic endAnchor = stream.getEndAnchor(nextOne.getBegin());
      ComposedRuleElementMatch extendedContainerMatch = containerMatch.copy();
      RuleMatch extendedMatch = ruleMatch.copy(extendedContainerMatch);
      AnnotationFS coveredByWildCard = getCoveredByWildCard(after, annotation, nextOne, stream);

      doMatch(coveredByWildCard, extendedMatch, extendedContainerMatch, annotation == null, stream,
View Full Code Here

    FSIterator<AnnotationFS> iterator = getIterator(after, annotation, nextElement, defaultType,
            stream);
    boolean doneHere = false;
    while (!doneHere && iterator.isValid() && stream.isVisible(iterator.get())) {
      AnnotationFS nextOne = iterator.get();
      RutaBasic endAnchor = stream.getEndAnchor(nextOne.getBegin());
      ComposedRuleElementMatch extendedContainerMatch = containerMatch.copy();
      RuleMatch extendedMatch = ruleMatch.copy(extendedContainerMatch);

      AnnotationFS coveredByWildCard = getCoveredByWildCard(after, annotation, nextOne, stream);
View Full Code Here

        nextElement.continueMatch(after, annotation, ruleMatch, ruleApply, containerMatch,
                sideStepOrigin, null, stream, crowd);
        doneHere = true;
        break;
      }
      RutaBasic anchor = stream.getAnchor(after, indexOf+delta);
      RutaBasic endAnchor = stream.getAnchor(!after, indexOf+delta);
      ComposedRuleElementMatch extendedContainerMatch = containerMatch.copy();
      RuleMatch extendedMatch = ruleMatch.copy(extendedContainerMatch);
      AnnotationFS coveredByWildCard = getCoveredByWildCard(after, annotation, anchor, stream);
      doMatch(coveredByWildCard, extendedMatch, extendedContainerMatch, annotation == null, stream,
              crowd);
View Full Code Here

      int localBegin = 0;
      int localEnd = 0;
      while (windowStream.isValid()) {
        FeatureStructure fs = windowStream.get();
        if (fs instanceof RutaBasic) {
          RutaBasic basic = (RutaBasic) fs;
          for (Type type : types) {
            Set<AnnotationFS> beginAnchors = basic.getBeginAnchors(type);
            for (AnnotationFS a : beginAnchors) {
              if (a != null && !a.getType().getName().equals("uima.tcas.DocumentAnnotation")
                      && !(a instanceof RutaBasic)) {
                fsToAdd.add(a);
              }
            }
          }
          int length = basic.getEnd() - basic.getBegin();
          localEnd = localBegin + length;

          new2oldBegin.put(localBegin, basic.getBegin());
          old2newBegin.put(basic.getBegin(), localBegin);
          new2oldEnd.put(localEnd, basic.getEnd());
          old2newEnd.put(basic.getEnd(), localEnd);

          newDocument.append(basic.getCoveredText());

          localBegin += length;
        }
        windowStream.moveToNext();
      }
View Full Code Here

  }

  private Collection<AnnotationFS> getNextAnnotations(boolean before, AnnotationFS annotation, RutaStream stream,
          RutaBlock parent) {
    List<AnnotationFS> result = new ArrayList<AnnotationFS>(1);
    RutaBasic basicNextTo = stream.getBasicNextTo(before, annotation);
    if(basicNextTo == null) {
      return result;
    }
    String stringValue = expression.getStringValue(parent);
    if(stringValue.equals(basicNextTo.getCoveredText())) {
      result.add(basicNextTo);
    }
    return result;
  }
View Full Code Here

    }
  }

  private boolean check(Type t, AnnotationFS annotation, RuleElement element,
          RutaStream stream) {
    RutaBasic beginAnchor = stream.getBeginAnchor(annotation.getBegin());
    Set<AnnotationFS> beginAnchors = beginAnchor.getBeginAnchors(t);
    return beginAnchor.isPartOf(t) || (beginAnchors != null && !beginAnchors.isEmpty());
  }
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.