private void updateReliabilityCount(String relationName, Node left, Node right, int flag) { relationReliabilityCount_.get(relationName)[flag]++; ConcurrentHashMap<Node, int[]> intermap = interRelastionReliabilityCount_.get(relationName); ConcurrentHashMap<Node, int[]> nodecountmap = nodeReliabilityCount_.get(relationName); ConcurrentHashMap<Pair<Node, Node>, ConcurrentLinkedQueue<Node>> unkmap = unknownBackups_.get(relationName); // Double loop to create pair of second order cyc isa parent from both // node // ArrayList<Node> leftIsa = getAllGenlsParents(left); // ArrayList<Node> rightIsa = getAllGenlsParents(right); // ArrayList<Node> commonparents = getCommomParents(leftIsa, rightIsa); Collection<DAGNode> commonparents = getCommonParents(left, right); for (Node node : commonparents) { if (!isTangible(node)) continue; if (!intermap.containsKey(node)) { intermap.put(node, new int[] {0, 0, 0}); } intermap.get(node)[flag]++; if (!nodecountmap.containsKey(node)) { nodecountmap.put(node, new int[] {0, 0, 0}); } nodecountmap.get(node)[flag]++; if (flag == 2) { // If it's unknown, add to unknown backups Pair<Node, Node> pair = null; int compare = left.getName().compareTo(right.getName()); if (compare < 0) { pair = new Pair<Node, Node>(left, right); } else if (compare > 0) { pair = new Pair<Node, Node>(right, left); } if (unkmap.get(pair) == null) unkmap.put(pair, new ConcurrentLinkedQueue<Node>()); unkmap.get(pair).add(node); } } }
private void createDisjointEdge(String relationName, Node left, Node right, PrintWriter out) { Pair<String, String> p = left.getName().hashCode() > right.getName().hashCode() ? new Pair<String, String>(left.getName(), right.getName()) : new Pair<String, String>(right.getName(), left.getName()); // check the pair has not being added if (dummyDisjoints_.containsKey(p)) return; ConcurrentHashMap<Node, int[]> nodecountmap = nodeReliabilityCount_.get(relationName); int leftconjCount = 0; int rightconjCount = 0; if (nodecountmap.get(left) != null) leftconjCount = nodecountmap.get(left)[1]; if (nodecountmap.get(right) != null) rightconjCount = nodecountmap.get(right)[1]; // Create disjoint out.println( left.getName() + "," + leftconjCount + "," + right.getName() + "," + rightconjCount + "," + relationName); // Node[] edge = new Node[] { CommonConcepts.DISJOINTWITH.getNode(dag_), // left, right }; // Node creator = new StringNode("ConceptNet" + relationName); // // dag_.findOrCreateEdge(edge, creator, true); // if (left.hashCode() > right.hashCode()) dummyDisjoints_.put(p, true); // else // dummyDisjoints_.put(rightKey, leftKey); }
private void updateSchema( String relationName, PrintWriter log, Node left, Node right, String nodename1, String nodename2) { Pair<String, String> p = left.getName().hashCode() > right.getName().hashCode() ? new Pair<String, String>(left.getName(), right.getName()) : new Pair<String, String>(right.getName(), left.getName()); ConcurrentHashMap<Pair<String, String>, Boolean> explored = uniquePairs_.get(relationName); if (explored.containsKey(p)) return; String outStr; if (!left.equals(right)) { if (isAlreadyDisjointed(left, right)) { updateReliabilityCount(relationName, left, right, 0); outStr = relationName + ": " + left.getName() + " known disjoint to " + right.getName() + ": " + nodename1 + "," + nodename2; } else if (hasConjoint(left, right)) { updateReliabilityCount(relationName, left, right, 1); outStr = relationName + ": " + left.getName() + " known conjoint to " + right.getName() + ": " + nodename1 + "," + nodename2; } else { updateReliabilityCount(relationName, left, right, 2); outStr = relationName + ": " + left.getName() + " unknown to " + right.getName() + ": " + nodename1 + "," + nodename2; } // System.out.println(outStr); log.println(outStr); } explored.put(p, true); }
private boolean isTangible(Node node) { // exclude itself if (node.equals(partiallyTangible)) return false; return queryModule_.prove(false, genls, node, partiallyTangible) == QueryResult.TRUE; }