Examples of RutaBasic


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

      return new EvaluatedCondition(this, result);
    }
  }

  private boolean check(Type t, AnnotationFS annotation, RuleElement element, RutaStream stream) {
    RutaBasic beginAnchor = stream.getBeginAnchor(annotation.getBegin());
    Collection<AnnotationFS> beginAnchors = beginAnchor.getBeginAnchors(t);
    return beginAnchor.isPartOf(t) || (beginAnchors != null && !beginAnchors.isEmpty());
  }
View Full Code Here

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();

      if (text.length() != 1 || !ignoreToken.contains(text)) {

        List<AnnotationFS> interResults = new ArrayList<AnnotationFS>();

        while (streamPointer.isValid()) {

          boolean skip = false;
          String currentBasicText = basicsToAdd.get(basicsToAdd.size()-1).getCoveredText();
          if (currentBasicText.length() == 1 && ignoreToken.contains(currentBasicText)) {
            skip = true;
          }
          List<String> types = null;
          if (!skip) {
            types = containsFragment(candidate.toString(), ignoreCase, ignoreLength, edit,
                    distance, ignoreToken);
          }
          if (skip || types != null) {
            streamPointer.moveToNext();
            if (streamPointer.isValid()) {
              RutaBasic next = (RutaBasic) streamPointer.get();
              // List<String> contains = contains(candidate,
              // ignoreCase,
              // ignoreLength, edit, distance, ignoreToken);
              if (!skip) {
                tryToCreateAnnotation(types, 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(types, stream, results, basicsToAdd, lastCandidate,
View Full Code Here

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

          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) {
        Collection<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

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

  }

  @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

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

  }

  @Override
  public EvaluatedCondition eval(AnnotationFS annotation, RuleElement element, RutaStream stream,
          InferenceCrowd crowd) {
    RutaBasic beginAnchor = stream.getBeginAnchor(annotation.getBegin());
    if (!isWorkingOnList()) {
      Collection<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(), stream);
      for (Type type : types) {
        Collection<AnnotationFS> beginAnchors = beginAnchor.getBeginAnchors(type);
        if (beginAnchors != null) {
          for (AnnotationFS annotationFS : beginAnchors) {
            result |= check(annotation, annotationFS);
            if (result == true) {
              break;
View Full Code Here

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

    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

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

      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

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(),
            annotation, stream);
View Full Code Here

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

  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

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

      return new EvaluatedCondition(this, result);
    }
  }

  private boolean check(AnnotationFS annotation, RutaStream stream, Type t) {
    RutaBasic beginAnchor = stream.getBeginAnchor(annotation.getBegin());
    RutaBasic endAnchor = stream.getEndAnchor(annotation.getEnd());
    boolean partOf = beginAnchor.isPartOf(t) || endAnchor.isPartOf(t);
    if (!partOf) {
      return false;
    }

    try {
      stream.moveTo(annotation);
    } catch (Exception e) {
    }
    while (stream.isValid()) {
      RutaBasic each = (RutaBasic) stream.get();
      Collection<AnnotationFS> set = each.getBeginAnchors(t);
      // TODO: maybe faster to move in the other direction?
      if (set == null) {
        stream.moveToPrevious();
        continue;
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.