Examples of RutaStream


Examples of org.apache.uima.ruta.RutaStream

      initializeTypes(script, cas);
      initialized = true;
      lastTypeSystem = cas.getTypeSystem();
    }
    InferenceCrowd crowd = initializeCrowd();
    RutaStream stream = initializeStream(cas, crowd);
    stream.setDynamicAnchoring(dynamicAnchoring);
    stream.setGreedyRuleElement(greedyRuleElement);
    stream.setGreedyRule(greedyRule);
    try {
      script.apply(stream, crowd);
    } catch (Throwable e) {
      throw new AnalysisEngineProcessException(AnalysisEngineProcessException.ANNOTATOR_EXCEPTION,
              new Object[] {}, e);
View Full Code Here

Examples of org.apache.uima.ruta.RutaStream

      }
    }
    FilterManager filter = new FilterManager(filterTypes, cas);
    Type basicType = typeSystem.getType(BASIC_TYPE);
    seedTypes = seedAnnotations(cas);
    RutaStream stream = new RutaStream(cas, basicType, filter, lowMemoryProfile,
            simpleGreedyForComposed, crowd);

    stream.initalizeBasics();
    return stream;
  }
View Full Code Here

Examples of org.apache.uima.ruta.RutaStream

        }
        boolean stop = false;
        List<Type> types = ((RutaRuleElement) rule.getRuleElements().get(0)).getMatcher().getTypes(
                getParent() == null ? this : getParent(), stream);
        for (Type eachType : types) {
          RutaStream window = stream.getWindowStream(each, eachType);
          for (RutaStatement element : getElements()) {
            if (stop)
              break;
            if (element != null) {
              ScriptApply elementApply = element.apply(window, crowd);
View Full Code Here

Examples of org.apache.uima.ruta.RutaStream

          continue;
        }
        List<Type> types = ((RutaRuleElement) rule.getRuleElements().get(0)).getMatcher().getTypes(
                getParent() == null ? this : getParent(), stream);
        for (Type eachType : types) {
          RutaStream window = stream.getWindowStream(each, eachType);
          List<RutaStatement> elements = new ArrayList<RutaStatement>(getElements());
          Collections.reverse(elements);
          for (RutaStatement element : elements) {
            if (element != null) {
              element.apply(window, crowd);
View Full Code Here

Examples of org.apache.uima.ruta.RutaStream

//    BlockApply blockApply = new BlockApply(this);
//    RuleApply dummyRuleApply = getDummyRuleApply(ruleMatch);
//    blockApply.setRuleApply(dummyRuleApply);
//    ruleMatch.addDelegateApply(this, blockApply);
    for (AnnotationFS annotationFS : matchedAnnotationsOf) {
      RutaStream windowStream = stream.getWindowStream(annotationFS, annotationFS.getType());
      for (RutaStatement each : inlinedRules) {
        ScriptApply apply = each.apply(windowStream, crowd);
//        blockApply.add(apply);
        ruleMatch.addDelegateApply(this, apply);
        result.add(apply);
View Full Code Here

Examples of org.apache.uima.ruta.RutaStream

        }
        boolean stop = false;
        List<Type> types = ((RutaRuleElement) rule.getRuleElements().get(0)).getMatcher().getTypes(
                getParent() == null ? this : getParent(), stream);
        for (Type eachType : types) {
          RutaStream window = stream.getWindowStream(each, eachType);
          for (RutaStatement element : getElements()) {
            if (stop)
              break;
            if (element != null) {
              ScriptApply elementApply = element.apply(window, crowd);
View Full Code Here

Examples of org.apache.uima.ruta.RutaStream

  @Override
  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
    List<AnnotationFS> matchedAnnotationsOf = match.getMatchedAnnotationsOf(element);
    for (AnnotationFS annotationFS : matchedAnnotationsOf) {
      RutaStream windowStream = stream.getWindowStream(annotationFS, annotationFS.getType());
      RutaWordList wl = null;
      RutaBlock parent = element.getParent();
      if (list != null) {
        wl = list.getList(parent);
      } else if (stringList != null) {
View Full Code Here

Examples of org.apache.uima.ruta.RutaStream

    if (block == null) {
      return;
    }
    List<AnnotationFS> matchedAnnotationsOf = match.getMatchedAnnotationsOf(element);
    for (AnnotationFS annotationFS : matchedAnnotationsOf) {
      RutaStream windowStream = stream.getWindowStream(annotationFS,
              stream.getDocumentAnnotationType());
      ScriptApply apply = block.apply(windowStream, crowd);
      match.addDelegateApply(this, apply);
    }
View Full Code Here

Examples of org.apache.uima.ruta.RutaStream

    List<AnnotationFS> matchedAnnotations = match.getMatchedAnnotations(null,
            element.getContainer());
    for (AnnotationFS matchedAnnotation : matchedAnnotations) {

      StringBuilder newDocument = new StringBuilder();
      RutaStream windowStream = stream.getWindowStream(matchedAnnotation,
              stream.getDocumentAnnotationType());
      windowStream.moveToFirst();

      CAS newCAS = targetEngine.newCAS();
      List<Type> types = newCAS.getTypeSystem()
              .getProperlySubsumedTypes(newCAS.getAnnotationType());

      Collection<AnnotationFS> fsToAdd = new HashSet<AnnotationFS>();

      Map<Integer, Integer> new2oldBegin = new TreeMap<Integer, Integer>();
      Map<Integer, Integer> new2oldEnd = new TreeMap<Integer, Integer>();
      Map<Integer, Integer> old2newBegin = new TreeMap<Integer, Integer>();
      Map<Integer, Integer> old2newEnd = new TreeMap<Integer, Integer>();

      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) {
            Collection<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();
      }

      String string = newDocument.toString();
      newCAS.setDocumentText(string);
      for (AnnotationFS each : fsToAdd) {
View Full Code Here

Examples of org.apache.uima.ruta.RutaStream

      initializeTypes(script, cas);
      initialized = true;
      lastTypeSystem = cas.getTypeSystem();
    }
    InferenceCrowd crowd = initializeCrowd();
    RutaStream stream = initializeStream(cas, crowd);
    stream.setDynamicAnchoring(dynamicAnchoring);
    stream.setGreedyRuleElement(greedyRuleElement);
    stream.setGreedyRule(greedyRule);
    try {
      script.apply(stream, crowd);
    } catch (Throwable e) {
      throw new AnalysisEngineProcessException(AnalysisEngineProcessException.ANNOTATOR_EXCEPTION,
              new Object[] {}, e);
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.