Examples of RutaStream


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

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

Examples of org.apache.uima.ruta.RutaStream

    if (!initialized || reloadScript) {
      initializeTypes(script, cas);
      initialized = true;
    }
    InferenceCrowd crowd = initializeCrowd();
    RutaStream stream = initializeStream(cas, crowd);
    stream.setDynamicAnchoring(dynamicAnchoring);
    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
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.