Package org.apache.uima.ruta.type

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


    List<DebugRuleMatch> ruleMatches = new ArrayList<DebugRuleMatch>();
    int begin = Integer.MAX_VALUE;
    int end = 0;
    if (withMatches) {
      for (AbstractRuleMatch<? extends AbstractRule> match : ruleApply.getList()) {
        DebugRuleMatch debugRuleMatch = createDebugRuleMatch(match, stream, addToIndex,
                withMatches, timeInfo);
        begin = Math.min(begin, debugRuleMatch.getBegin());
        end = Math.max(end, debugRuleMatch.getEnd());
        ruleMatches.add(debugRuleMatch);
      }
    }
    if (begin >= end) {
      begin = end;
View Full Code Here


  public DebugRuleMatch createDebugRuleMatch(AbstractRuleMatch<? extends AbstractRule> match,
          RutaStream stream, boolean addToIndex, boolean withMatches,
          Map<RutaElement, Long> timeInfo) {
    JCas cas = stream.getJCas();
    DebugRuleMatch drm = null;
    if (match.matchedCompletely()) {
      drm = new DebugMatchedRuleMatch(cas);
    } else {
      drm = new DebugFailedRuleMatch(cas);
    }
    drm.setMatched(match.matchedCompletely());
    if (match instanceof RuleMatch) {
      ComposedRuleElementMatch rootMatch = ((RuleMatch) match).getRootMatch();
      setInnerMatches(stream, addToIndex, cas, drm, rootMatch);
//      if (match.matched()) {
        List<DebugScriptApply> delegates = new ArrayList<DebugScriptApply>();
        for (ScriptApply rem : ((RuleMatch) match).getDelegateApply().values()) {
          delegates.add(createDebugScriptApply(rem, stream, addToIndex, withMatches, timeInfo));
        }
        drm.setDelegates(UIMAUtils.toFSArray(cas, delegates));
//      }
    } else if (match instanceof RegExpRuleMatch) {
      RegExpRuleMatch rerm = (RegExpRuleMatch) match;
      Map<Integer, List<AnnotationFS>> map = rerm.getMap();
      Set<Entry<Integer, List<AnnotationFS>>> entrySet = map.entrySet();
      List<DebugRuleElementMatches> ruleElementMatches = new ArrayList<DebugRuleElementMatches>();
      for (Entry<Integer, List<AnnotationFS>> entry : entrySet) {
        DebugRuleElementMatches drems = new DebugRuleElementMatches(cas);
        RegExpRule rule = rerm.getRule();
        Integer key = entry.getKey();
        List<AnnotationFS> value = entry.getValue();
        drems.setElement(verbalizer.verbalize(rule));
        List<DebugRuleElementMatch> remList = new ArrayList<DebugRuleElementMatch>();
        if (value != null) {
          for (AnnotationFS each : value) {
            DebugRuleElementMatch drem = new DebugRuleElementMatch(cas);

            DebugEvaluatedCondition base = new DebugEvaluatedCondition(cas);
            base.setValue(true);
            String baseString = "Group " + key;
            base.setElement(baseString);
            drem.setBaseCondition(base);

            drem.setBegin(each.getBegin());
            drem.setEnd(each.getEnd());
            if (addToIndex) {
              drem.addToIndexes();
            }
            remList.add(drem);
          }
        }
        drems.setMatches(UIMAUtils.toFSArray(cas, remList));
        if (addToIndex) {
          drems.addToIndexes();
        }
        ruleElementMatches.add(drems);
      }

      drm.setElements(UIMAUtils.toFSArray(cas, ruleElementMatches));
    }
    if (timeInfo != null) {
      long time = timeInfo.get(match.getRule());
      drm.setTime(time);
    }
    List<AnnotationFS> matchedAnnotationsOfRoot = match.getMatchedAnnotationsOfRoot();
    if (!matchedAnnotationsOfRoot.isEmpty()) {
      AnnotationFS matchedAnnotation = matchedAnnotationsOfRoot.get(0);
      if (matchedAnnotation != null) {
        drm.setBegin(matchedAnnotation.getBegin());
        drm.setEnd(matchedAnnotation.getEnd());
        if (addToIndex || withMatches)
          drm.addToIndexes();
      }
    }
    return drm;
  }
View Full Code Here

    List<DebugRuleMatch> ruleMatches = new ArrayList<DebugRuleMatch>();
    int begin = Integer.MAX_VALUE;
    int end = 0;
    if (withMatches) {
      for (AbstractRuleMatch<? extends AbstractRule> match : ruleApply.getList()) {
        DebugRuleMatch debugRuleMatch = createDebugRuleMatch(match, stream, addToIndex,
                withMatches, timeInfo);
        begin = Math.min(begin, debugRuleMatch.getBegin());
        end = Math.max(end, debugRuleMatch.getEnd());
        ruleMatches.add(debugRuleMatch);
      }
    }
    if (begin >= end) {
      begin = end;
View Full Code Here

  public DebugRuleMatch createDebugRuleMatch(AbstractRuleMatch<? extends AbstractRule> match,
          RutaStream stream, boolean addToIndex, boolean withMatches,
          Map<RutaElement, Long> timeInfo) {
    JCas cas = stream.getJCas();
    DebugRuleMatch drm = null;
    if (match.matchedCompletely()) {
      drm = new DebugMatchedRuleMatch(cas);
    } else {
      drm = new DebugFailedRuleMatch(cas);
    }
    drm.setMatched(match.matchedCompletely());
    if (match instanceof RuleMatch) {
      ComposedRuleElementMatch rootMatch = ((RuleMatch) match).getRootMatch();
      setInnerMatches(stream, addToIndex, cas, drm, rootMatch);
      if (match.matched()) {
        List<DebugScriptApply> delegates = new ArrayList<DebugScriptApply>();
        for (ScriptApply rem : ((RuleMatch) match).getDelegateApply().values()) {
          delegates.add(createDebugScriptApply(rem, stream, addToIndex, withMatches, timeInfo));
        }
        drm.setDelegates(UIMAUtils.toFSArray(cas, delegates));
      }
    } else if (match instanceof RegExpRuleMatch) {
      RegExpRuleMatch rerm = (RegExpRuleMatch) match;
      Map<Integer, List<AnnotationFS>> map = rerm.getMap();
      Set<Entry<Integer, List<AnnotationFS>>> entrySet = map.entrySet();
      List<DebugRuleElementMatches> ruleElementMatches = new ArrayList<DebugRuleElementMatches>();
      for (Entry<Integer, List<AnnotationFS>> entry : entrySet) {
        DebugRuleElementMatches drems = new DebugRuleElementMatches(cas);
        RegExpRule rule = rerm.getRule();
        Integer key = entry.getKey();
        List<AnnotationFS> value = entry.getValue();
        drems.setElement(verbalizer.verbalize(rule));
        List<DebugRuleElementMatch> remList = new ArrayList<DebugRuleElementMatch>();
        if (value != null) {
          for (AnnotationFS each : value) {
            DebugRuleElementMatch drem = new DebugRuleElementMatch(cas);

            DebugEvaluatedCondition base = new DebugEvaluatedCondition(cas);
            base.setValue(true);
            String baseString = "Group " + key;
            base.setElement(baseString);
            drem.setBaseCondition(base);

            drem.setBegin(each.getBegin());
            drem.setEnd(each.getEnd());
            if (addToIndex) {
              drem.addToIndexes();
            }
            remList.add(drem);
          }
        }
        drems.setMatches(UIMAUtils.toFSArray(cas, remList));
        if (addToIndex) {
          drems.addToIndexes();
        }
        ruleElementMatches.add(drems);
      }

      drm.setElements(UIMAUtils.toFSArray(cas, ruleElementMatches));
    }
    if (timeInfo != null) {
      long time = timeInfo.get(match.getRule());
      drm.setTime(time);
    }
    List<AnnotationFS> matchedAnnotationsOfRoot = match.getMatchedAnnotationsOfRoot(stream);
    if (!matchedAnnotationsOfRoot.isEmpty()) {
      AnnotationFS matchedAnnotation = matchedAnnotationsOfRoot.get(0);
      if (matchedAnnotation != null) {
        drm.setBegin(matchedAnnotation.getBegin());
        drm.setEnd(matchedAnnotation.getEnd());
        if (addToIndex || withMatches)
          drm.addToIndexes();
      }
    }
    return drm;
  }
View Full Code Here

    List<DebugRuleMatch> ruleMatches = new ArrayList<DebugRuleMatch>();
    int begin = Integer.MAX_VALUE;
    int end = 0;
    if (withMatches) {
      for (AbstractRuleMatch<? extends AbstractRule> match : ruleApply.getList()) {
        DebugRuleMatch debugRuleMatch = createDebugRuleMatch(match, stream, addToIndex,
                withMatches, timeInfo);
        begin = Math.min(begin, debugRuleMatch.getBegin());
        end = Math.max(end, debugRuleMatch.getEnd());
        ruleMatches.add(debugRuleMatch);
      }
    }
    if (begin >= end) {
      begin = end;
View Full Code Here

  public DebugRuleMatch createDebugRuleMatch(AbstractRuleMatch<? extends AbstractRule> match,
          RutaStream stream, boolean addToIndex, boolean withMatches,
          Map<RutaElement, Long> timeInfo) {
    JCas cas = stream.getJCas();
    DebugRuleMatch drm = null;
    if (match.matchedCompletely()) {
      drm = new DebugMatchedRuleMatch(cas);
    } else {
      drm = new DebugFailedRuleMatch(cas);
    }
    drm.setMatched(match.matchedCompletely());
    if (match instanceof RuleMatch) {
      ComposedRuleElementMatch rootMatch = ((RuleMatch) match).getRootMatch();
      setInnerMatches(stream, addToIndex, cas, drm, rootMatch);
//      if (match.matched()) {
        List<DebugScriptApply> delegates = new ArrayList<DebugScriptApply>();
        for (ScriptApply rem : ((RuleMatch) match).getDelegateApply().values()) {
          delegates.add(createDebugScriptApply(rem, stream, addToIndex, withMatches, timeInfo));
        }
        drm.setDelegates(UIMAUtils.toFSArray(cas, delegates));
//      }
    } else if (match instanceof RegExpRuleMatch) {
      RegExpRuleMatch rerm = (RegExpRuleMatch) match;
      Map<Integer, List<AnnotationFS>> map = rerm.getMap();
      Set<Entry<Integer, List<AnnotationFS>>> entrySet = map.entrySet();
      List<DebugRuleElementMatches> ruleElementMatches = new ArrayList<DebugRuleElementMatches>();
      for (Entry<Integer, List<AnnotationFS>> entry : entrySet) {
        DebugRuleElementMatches drems = new DebugRuleElementMatches(cas);
        RegExpRule rule = rerm.getRule();
        Integer key = entry.getKey();
        List<AnnotationFS> value = entry.getValue();
        drems.setElement(verbalizer.verbalize(rule));
        List<DebugRuleElementMatch> remList = new ArrayList<DebugRuleElementMatch>();
        if (value != null) {
          for (AnnotationFS each : value) {
            DebugRuleElementMatch drem = new DebugRuleElementMatch(cas);

            DebugEvaluatedCondition base = new DebugEvaluatedCondition(cas);
            base.setValue(true);
            String baseString = "Group " + key;
            base.setElement(baseString);
            drem.setBaseCondition(base);

            drem.setBegin(each.getBegin());
            drem.setEnd(each.getEnd());
            if (addToIndex) {
              drem.addToIndexes();
            }
            remList.add(drem);
          }
        }
        drems.setMatches(UIMAUtils.toFSArray(cas, remList));
        if (addToIndex) {
          drems.addToIndexes();
        }
        ruleElementMatches.add(drems);
      }

      drm.setElements(UIMAUtils.toFSArray(cas, ruleElementMatches));
    }
    if (timeInfo != null) {
      long time = timeInfo.get(match.getRule());
      drm.setTime(time);
    }
    List<AnnotationFS> matchedAnnotationsOfRoot = match.getMatchedAnnotationsOfRoot();
    if (!matchedAnnotationsOfRoot.isEmpty()) {
      AnnotationFS matchedAnnotation = matchedAnnotationsOfRoot.get(0);
      if (matchedAnnotation != null) {
        drm.setBegin(matchedAnnotation.getBegin());
        drm.setEnd(matchedAnnotation.getEnd());
        if (addToIndex || withMatches)
          drm.addToIndexes();
      }
    }
    return drm;
  }
View Full Code Here

TOP

Related Classes of org.apache.uima.ruta.type.DebugRuleMatch

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.