private boolean hasConjoint(Node nodeA, Node nodeB) { if (isAlreadyDisjointed(nodeA, nodeB)) return false; // Check they are not Genls to each other if (queryModule_.prove(false, CommonConcepts.GENLS.getNode(dag_), nodeA, nodeB) == QueryResult.TRUE || queryModule_.prove(false, CommonConcepts.GENLS.getNode(dag_), nodeB, nodeA) == QueryResult.TRUE) return true; // Check they do not have genls conjoint point VariableNode x = VariableNode.DEFAULT; QueryObject qo = new QueryObject( and, new OntologyFunction(genls, x, nodeA), new OntologyFunction(genls, x, nodeB)); Collection<Substitution> results = queryModule_.executeQuery(qo); if (results.size() != 0) { return true; } // Check they do not have isa conjoint point x = VariableNode.DEFAULT; qo = new QueryObject( and, new OntologyFunction(isa, x, nodeA), new OntologyFunction(isa, x, nodeB)); results = queryModule_.executeQuery(qo); if (results.size() != 0) { return true; } return false; }
/** * Checks consistency of the current node against all other collections in the group. * * @param comparisonNode The node to check consistency against * @param group The group against whcih to check. * @param cache Disjoint query cache * @return True if the node is consistent with all nodes in the group. False otherwise. */ private boolean isConsistent( DAGNode comparisonNode, Collection<DAGNode> group, Map<String, QueryResult> cache) { String compID = comparisonNode.getIdentifier(); for (DAGNode n : group) { if (n.equals(comparisonNode)) continue; // Create cache string to check for existing results. String nID = n.getIdentifier(); String cacheStr = (nID.compareTo(compID) < 0) ? nID + compID : compID + nID; QueryResult result = null; if (!cache.containsKey(cacheStr)) { // Ask the disjoint query QueryObject qo = new QueryObject( false, false, QueryResult.TRUE, CommonConcepts.DISJOINTWITH.getNode(dag_), comparisonNode, n); result = queryModule_.prove(qo); cache.put(cacheStr, result); } else result = cache.get(cacheStr); if (result == QueryResult.TRUE) return false; } return true; }
private ArrayList<Node> removeMaterials(ArrayList<Node> candidates) { Node material = (DAGNode) dag_.findOrCreateNode("CommonSubstances-Material-Topic", null, true); ArrayList<Node> r = new ArrayList<Node>(); for (Node node : candidates) { if (queryModule_.prove(false, isa, node, material) != QueryResult.TRUE) r.add(node); } return r; }
private boolean isCollection(DAGNode node) { QueryObject qo = new QueryObject( false, false, QueryResult.TRUE, CommonConcepts.ISA.getNode(dag_), node, CommonConcepts.COLLECTION.getNode(dag_)); return queryModule_.prove(qo) == QueryResult.TRUE; }
private boolean isTangible(Node node) { // exclude itself if (node.equals(partiallyTangible)) return false; return queryModule_.prove(false, genls, node, partiallyTangible) == QueryResult.TRUE; }
private boolean isSecondOrderCollection(Node node) { return queryModule_.prove(false, isa, node, secondordercyc) == QueryResult.TRUE; }
// is na a child of nb? private boolean isChild(Node na, Node nb) { return queryModule_.prove(false, genls, na, nb) == QueryResult.TRUE; }
private boolean isAlreadyDisjointed(Node targetNode, Node child) { return queryModule_.prove(false, CommonConcepts.DISJOINTWITH.getNode(dag_), targetNode, child) == QueryResult.TRUE; }