Examples of IExplainTreeNode


Examples of org.apache.uima.ruta.explain.tree.IExplainTreeNode

public class FailedTreeContentProvider implements ITreeContentProvider {

  public Object[] getChildren(Object parentElement) {
    if (parentElement instanceof IExplainTreeNode) {
      List<Object> result = new ArrayList<Object>();
      IExplainTreeNode debugNode = (IExplainTreeNode) parentElement;
      for (IExplainTreeNode each : debugNode.getChildren()) {
        if (each instanceof RuleMatchNode) {
          result.add(each);
        }
      }
      return result.toArray();
View Full Code Here

Examples of org.apache.uima.ruta.explain.tree.IExplainTreeNode

public class ElementTreeContentProvider implements ITreeContentProvider {

  public Object[] getChildren(Object parentElement) {
    if (parentElement instanceof IExplainTreeNode) {
      IExplainTreeNode debugNode = (IExplainTreeNode) parentElement;
      return debugNode.getChildren().toArray();
    }
    return null;
  }
View Full Code Here

Examples of org.apache.uima.ruta.explain.tree.IExplainTreeNode

    return getChildren(element);
  }

  public boolean hasChildren(Object parentElement) {
    if (parentElement instanceof IExplainTreeNode) {
      IExplainTreeNode debugNode = (IExplainTreeNode) parentElement;
      return debugNode.hasChildren();
    }
    return false;
  }
View Full Code Here

Examples of org.apache.uima.ruta.explain.tree.IExplainTreeNode

  }

  private void filterTree(ExplainTree tree) {
    Type ruleType = document.getCAS().getTypeSystem().getType(ExplainConstants.RULE_APPLY_TYPE);
    IExplainTreeNode root = tree.getRoot();
    List<IExplainTreeNode> children = new ArrayList<IExplainTreeNode>(root.getChildren());
    for (IExplainTreeNode each : children) {
      if (each instanceof RuleApplyNode) {
        RuleApplyNode ran = (RuleApplyNode) each;
        Feature f = ruleType.getFeatureByBaseName(ExplainConstants.ELEMENT);
        if (f != null) {
          String v = ran.getFeatureStructure().getStringValue(f);
          if (!StringUtils.isEmpty(manualFilter) && v.indexOf(manualFilter) == -1) {
            root.removeChild(ran);
          }
        }
      }
    }
  }
View Full Code Here

Examples of org.apache.uima.ruta.explain.tree.IExplainTreeNode

  }

  @Override
  public Image getImage(Object element) {
    if (element instanceof IExplainTreeNode) {
      IExplainTreeNode debugNode = (IExplainTreeNode) element;
      FeatureStructure fs = debugNode.getFeatureStructure();
      if (fs != null) {
        String name = fs.getType().getName();
        if (name.equals(ExplainConstants.RULE_APPLY_TYPE)) {
          if (debugNode.getChildren().size() >= 3) {
            name += "Delegate";
          }
        }
        return owner.getImage(name);
      }
View Full Code Here

Examples of org.apache.uima.ruta.explain.tree.IExplainTreeNode

  @Override
  public String getText(Object element) {

    String result = "error";
    if (element instanceof IExplainTreeNode) {
      IExplainTreeNode debugNode = (IExplainTreeNode) element;
      TypeSystem ts = debugNode.getTypeSystem();

      Type ruleType = ts.getType(ExplainConstants.RULE_APPLY_TYPE);
      FeatureStructure fs = debugNode.getFeatureStructure();
      if (fs != null && ts.subsumes(ruleType, fs.getType())) {
        Feature f1 = ruleType.getFeatureByBaseName(ExplainConstants.APPLIED);
        int v1 = fs.getIntValue(f1);
        Feature f2 = ruleType.getFeatureByBaseName(ExplainConstants.TRIED);
        int v2 = fs.getIntValue(f2);
        Feature f3 = ruleType.getFeatureByBaseName(ExplainConstants.ELEMENT);
        String v3 = fs.getStringValue(f3);
        v3 = v3.replaceAll("[\\n\\r]", "");
        Feature f4 = ruleType.getFeatureByBaseName(ExplainConstants.TIME);
        long v4 = fs.getLongValue(f4);
        String time = "";
        if (v4 > 0.0) {
          double took = v4 / 1000.0;
          time = " [" + took + "s";
          IExplainTreeNode parentNode = debugNode.getParent();
          if (parentNode != null) {
            FeatureStructure parent = parentNode.getFeatureStructure();
            if (parent != null) {
              long parentTime = parent.getLongValue(f4);
              double percent = (took / (parentTime / 1000.0)) * 100.0;
              percent = Math.round(percent * 100.0) / 100.0;
              time += "|" + percent + "%]";
View Full Code Here

Examples of org.apache.uima.ruta.explain.tree.IExplainTreeNode

public class ApplyTreeContentProvider implements ITreeContentProvider {

  public Object[] getChildren(Object parentElement) {
    if (parentElement instanceof IExplainTreeNode) {
      List<Object> result = new ArrayList<Object>();
      IExplainTreeNode debugNode = (IExplainTreeNode) parentElement;
      for (IExplainTreeNode each : debugNode.getChildren()) {
        if (!(each instanceof ExplainRootNode)) {
          result.add(each);
        }
      }
      return result.toArray();
View Full Code Here

Examples of org.apache.uima.ruta.explain.tree.IExplainTreeNode

    return getChildren(parentElement);
  }

  public boolean hasChildren(Object parentElement) {
    if (parentElement instanceof IExplainTreeNode) {
      IExplainTreeNode debugNode = (IExplainTreeNode) parentElement;
      for (Object each : debugNode.getChildren()) {
        if (!(each instanceof ExplainRootNode)) {
          return true;
        }
      }
    }
View Full Code Here

Examples of org.apache.uima.ruta.explain.tree.IExplainTreeNode

public class MatchedTreeContentProvider implements ITreeContentProvider {

  public Object[] getChildren(Object parentElement) {
    if (parentElement instanceof IExplainTreeNode) {
      List<Object> result = new ArrayList<Object>();
      IExplainTreeNode debugNode = (IExplainTreeNode) parentElement;
      for (IExplainTreeNode each : debugNode.getChildren()) {
        if (each instanceof RuleMatchNode) {
          result.add(each);
        }
      }
      return result.toArray();
View Full Code Here

Examples of org.apache.uima.ruta.explain.tree.IExplainTreeNode

  }

  @Override
  public String getText(Object element) {
    if (element instanceof IExplainTreeNode) {
      IExplainTreeNode debugNode = (IExplainTreeNode) element;
      TypeSystem ts = debugNode.getTypeSystem();

      if (element instanceof RuleElementMatchesNode) {
        Type type = ts.getType(ExplainConstants.RULE_ELEMENT_MATCHES_TYPE);
        FeatureStructure fs = debugNode.getFeatureStructure();
        Feature f = type.getFeatureByBaseName(ExplainConstants.ELEMENT);
        Feature fanchor = type.getFeatureByBaseName(ExplainConstants.RULE_ANCHOR);
        if (f != null && fanchor != null) {
          String v = fs.getStringValue(f);
          return v;
        }
      } else if (element instanceof RuleElementMatchNode) {
        FeatureStructure fs = debugNode.getFeatureStructure();
        if (fs instanceof AnnotationFS) {
          String s = ((AnnotationFS) fs).getCoveredText();
          s = s.replaceAll("[\\n\\r]", "");

          return s;
        }
      } else if (element instanceof ConditionNode) {
        Type type = ts.getType(ExplainConstants.EVAL_CONDITION_TYPE);
        FeatureStructure fs = debugNode.getFeatureStructure();
        Feature f = type.getFeatureByBaseName(ExplainConstants.ELEMENT);
        if (f != null) {
          String v = fs.getStringValue(f);
          return v;
        }
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.