public ExplanationTree getOrderedExplanation(OWLAxiom entailment, Set<OWLAxiom> axioms) { ExplanationTree root = new ExplanationTree(entailment); for(OWLAxiom ax : axioms) { root.addChild(new ExplanationTree(ax)); } return root; } }
private static void sortChildrenAxioms(ExplanationTree tree) { tree.sortChildren(COMPARATOR); }
private void insertChildren(@Nullable OWLEntity entity, ExplanationTree tree) { if (entity == null) { return; } Set<OWLAxiom> currentPath = new HashSet<>(tree.getUserObjectPathToRoot()); getAxioms(entity).filter(ax -> !passTypes.contains(ax.getAxiomType())).forEach(ax -> { Set<OWLAxiom> mapped = getIndexedSet(entity, mappedAxioms, true); if (!consumedAxioms.contains(ax) && !mapped.contains(ax) && !currentPath.contains(ax)) { mapped.add(ax); consumedAxioms.add(ax); ExplanationTree child = new ExplanationTree(ax); tree.addChild(child); getRHSEntitiesSorted(ax).forEach(ent -> insertChildren(ent, child)); } }); sortChildrenAxioms(tree); }
@Override public ExplanationTree getOrderedExplanation(OWLAxiom entailment, Set<OWLAxiom> current) { currentExplanation = new HashSet<>(current); buildIndices(); ExplanationTree root = new EntailedAxiomTree(entailment); insertChildren(seedExtractor.getSource(entailment), root); OWLEntity currentTarget = seedExtractor.getTarget(entailment); Set<OWLAxiom> axs = root.getUserObjectClosure(); List<OWLAxiom> rootAxioms = new ArrayList<>(); for (OWLAxiom ax : current) { if (!axs.contains(ax)) { rootAxioms.add(ax); } } Set<OWLAxiom> targetAxioms = getTargetAxioms(currentTarget); Collections.sort(rootAxioms, (o1, o2) -> { if (targetAxioms.contains(o1)) { return 1; } if (targetAxioms.contains(o2)) { return -1; } return 0; }); rootAxioms.forEach(ax -> root.addChild(new ExplanationTree(ax))); return root; }
@Override public ExplanationTree getOrderedExplanation(OWLAxiom entailment, Set<OWLAxiom> axioms) { EntailedAxiomTree root = new EntailedAxiomTree(entailment); List<OWLAxiom> sortedAxioms = new ArrayList<>(axioms); Collections.sort(sortedAxioms, Comparator.comparing(renderer::render)); sortedAxioms.forEach(ax -> root.addChild(new ExplanationTree(ax))); return root; } }
@Override public String toString() { StringBuilder sb = new StringBuilder(); if (justification.isEmpty()) { return "Explanation: <Empty>\n"; } sb.append("Explanation <"); sb.append(entailment); sb.append(">\n"); Collection<OWLAxiom> orderedAxioms; if (entailment instanceof OWLAxiom) { OWLAxiom entailedAxiom = (OWLAxiom) entailment; ExplanationOrderer orderer = new ExplanationOrdererImplNoManager(); List<OWLAxiom> axs = new ArrayList<>(orderer.getOrderedExplanation(entailedAxiom, justification).fillDepthFirst()); axs.remove(0); orderedAxioms = axs; } else { orderedAxioms = new TreeSet<>(justification); } for (OWLAxiom ax : orderedAxioms) { sb.append("\t"); sb.append(ax); sb.append("\n"); } return sb.toString(); }
private void insertChildren(@Nullable OWLEntity entity, ExplanationTree tree) { if (entity == null) { return; } Set<OWLAxiom> currentPath = new HashSet<>(tree.getUserObjectPathToRoot()); getAxioms(entity).filter(ax -> !passTypes.contains(ax.getAxiomType())).forEach(ax -> { Set<OWLAxiom> mapped = getIndexedSet(entity, mappedAxioms, true); if (!consumedAxioms.contains(ax) && !mapped.contains(ax) && !currentPath.contains(ax)) { mapped.add(ax); consumedAxioms.add(ax); ExplanationTree child = new ExplanationTree(ax); tree.addChild(child); getRHSEntitiesSorted(ax).forEach(ent -> insertChildren(ent, child)); } }); sortChildrenAxioms(tree); }
@Override public ExplanationTree getOrderedExplanation(OWLAxiom entailment, Set<OWLAxiom> axioms) { currentExplanation = new HashSet<>(axioms); buildIndices(); ExplanationTree root = new EntailedAxiomTree(entailment); insertChildren(seedExtractor.getSource(entailment), root); OWLEntity currentTarget = seedExtractor.getTarget(entailment); Set<OWLAxiom> axs = root.getUserObjectClosure(); List<OWLAxiom> rootAxioms = new ArrayList<>(); for (OWLAxiom ax : axioms) { if (!axs.contains(ax)) { rootAxioms.add(ax); } } Set<OWLAxiom> targetAxioms = getTargetAxioms(currentTarget); Collections.sort(rootAxioms, (o1, o2) -> { if (targetAxioms.contains(o1)) { return 1; } if (targetAxioms.contains(o2)) { return -1; } return 0; }); rootAxioms.forEach(ax -> root.addChild(new ExplanationTree(ax))); return root; }
@Override public ExplanationTree getOrderedExplanation(OWLAxiom entailment, Set<OWLAxiom> axioms) { EntailedAxiomTree root = new EntailedAxiomTree(entailment); List<OWLAxiom> sortedAxioms = new ArrayList<>(axioms); Collections.sort(sortedAxioms, Comparator.comparing(renderer::render)); sortedAxioms.forEach(ax -> root.addChild(new ExplanationTree(ax))); return root; } }
private void insertChildren(@Nullable OWLEntity entity, ExplanationTree tree) { if (entity == null) { return; } Set<OWLAxiom> currentPath = new HashSet<>(tree.getUserObjectPathToRoot()); getAxioms(entity).filter(ax -> !passTypes.contains(ax.getAxiomType())).forEach(ax -> { Set<OWLAxiom> mapped = getIndexedSet(entity, mappedAxioms, true); if (!consumedAxioms.contains(ax) && !mapped.contains(ax) && !currentPath.contains(ax)) { mapped.add(ax); consumedAxioms.add(ax); ExplanationTree child = new ExplanationTree(ax); tree.addChild(child); getRHSEntitiesSorted(ax).forEach(ent -> insertChildren(ent, child)); } }); sortChildrenAxioms(tree); }
@Override public ExplanationTree getOrderedExplanation(OWLAxiom entailment, Set<OWLAxiom> axioms) { currentExplanation = new HashSet<>(axioms); buildIndices(); ExplanationTree root = new EntailedAxiomTree(entailment); insertChildren(seedExtractor.getSource(entailment), root); OWLEntity currentTarget = seedExtractor.getTarget(entailment); Set<OWLAxiom> axs = root.getUserObjectClosure(); List<OWLAxiom> rootAxioms = new ArrayList<>(); for (OWLAxiom ax : axioms) { if (!axs.contains(ax)) { rootAxioms.add(ax); } } Set<OWLAxiom> targetAxioms = getTargetAxioms(currentTarget); Collections.sort(rootAxioms, (o1, o2) -> { if (targetAxioms.contains(o1)) { return 1; } if (targetAxioms.contains(o2)) { return -1; } return 0; }); rootAxioms.forEach(ax -> root.addChild(new ExplanationTree(ax))); return root; }
@Override public ExplanationTree getOrderedExplanation(OWLAxiom entailment, Set<OWLAxiom> axioms) { ExplanationTree root = new ExplanationTree(entailment); axioms.forEach(ax -> root.addChild(new ExplanationTree(ax))); return root; } }
private static void sortChildrenAxioms(ExplanationTree tree) { tree.sortChildren(COMPARATOR); }
@Override public ExplanationTree getOrderedExplanation(OWLAxiom entailment, Set<OWLAxiom> axioms) { EntailedAxiomTree root = new EntailedAxiomTree(entailment); List<OWLAxiom> sortedAxioms = new ArrayList<>(axioms); Collections.sort(sortedAxioms, Comparator.comparing(renderer::render)); sortedAxioms.forEach(ax -> root.addChild(new ExplanationTree(ax))); return root; } }
private void insertChildren(@Nullable OWLEntity entity, ExplanationTree tree) { if (entity == null) { return; } Set<OWLAxiom> currentPath = new HashSet<>(tree.getUserObjectPathToRoot()); getAxioms(entity).filter(ax -> !passTypes.contains(ax.getAxiomType())).forEach(ax -> { Set<OWLAxiom> mapped = getIndexedSet(entity, mappedAxioms, true); if (!consumedAxioms.contains(ax) && !mapped.contains(ax) && !currentPath.contains(ax)) { mapped.add(ax); consumedAxioms.add(ax); ExplanationTree child = new ExplanationTree(ax); tree.addChild(child); getRHSEntitiesSorted(ax).forEach(ent -> insertChildren(ent, child)); } }); sortChildrenAxioms(tree); }
@Override public ExplanationTree getOrderedExplanation(OWLAxiom entailment, Set<OWLAxiom> axioms) { currentExplanation = new HashSet<>(axioms); buildIndices(); ExplanationTree root = new EntailedAxiomTree(entailment); insertChildren(seedExtractor.getSource(entailment), root); OWLEntity currentTarget = seedExtractor.getTarget(entailment); Set<OWLAxiom> axs = root.getUserObjectClosure(); List<OWLAxiom> rootAxioms = new ArrayList<>(); for (OWLAxiom ax : axioms) { if (!axs.contains(ax)) { rootAxioms.add(ax); } } Set<OWLAxiom> targetAxioms = getTargetAxioms(currentTarget); Collections.sort(rootAxioms, (o1, o2) -> { if (targetAxioms.contains(o1)) { return 1; } if (targetAxioms.contains(o2)) { return -1; } return 0; }); rootAxioms.forEach(ax -> root.addChild(new ExplanationTree(ax))); return root; }
@Override public ExplanationTree getOrderedExplanation(OWLAxiom entailment, Set<OWLAxiom> axioms) { ExplanationTree root = new ExplanationTree(entailment); axioms.forEach(ax -> root.addChild(new ExplanationTree(ax))); return root; } }
private static void sortChildrenAxioms(ExplanationTree tree) { tree.sortChildren(COMPARATOR); }
@Override public ExplanationTree getOrderedExplanation(OWLAxiom entailment, Set<OWLAxiom> axioms) { EntailedAxiomTree root = new EntailedAxiomTree(entailment); List<OWLAxiom> sortedAxioms = new ArrayList<>(axioms); Collections.sort(sortedAxioms, Comparator.comparing(renderer::render)); sortedAxioms.forEach(ax -> root.addChild(new ExplanationTree(ax))); return root; } }
private void insertChildren(@Nullable OWLEntity entity, ExplanationTree tree) { if (entity == null) { return; } Set<OWLAxiom> currentPath = new HashSet<>(tree.getUserObjectPathToRoot()); getAxioms(entity).filter(ax -> !passTypes.contains(ax.getAxiomType())).forEach(ax -> { Set<OWLAxiom> mapped = getIndexedSet(entity, mappedAxioms, true); if (!consumedAxioms.contains(ax) && !mapped.contains(ax) && !currentPath.contains(ax)) { mapped.add(ax); consumedAxioms.add(ax); ExplanationTree child = new ExplanationTree(ax); tree.addChild(child); getRHSEntitiesSorted(ax).forEach(ent -> insertChildren(ent, child)); } }); sortChildrenAxioms(tree); }