public PredicateExistenceFilterDBpedia(SparqlEndpointKS ks) { this.ks = ks; Set<Node> existentialMeaninglessProperties = new TreeSet<>(new NodeComparator()); try { List<String> lines = Files.readLines(new File(this.getClass().getClassLoader().getResource(PATH).toURI()), Charsets.UTF_8); for (String line : lines) { if(!line.trim().isEmpty() && !line.startsWith("#")) { existentialMeaninglessProperties.add(NodeFactory.createURI(line.trim())); } } } catch (IOException | URISyntaxException e) { e.printStackTrace(); } setExistentialMeaninglessProperties(existentialMeaninglessProperties); }
@Override public int compareTo(NodeInv o) { if(this.getClass().equals(o.getClass())) { return new NodeComparator().compare(this, o); } else { return -1; } } }
@Override public int compare(Node o1, Node o2) { int val1 = o1 instanceof NodeInv ? 1 : 0; int val2 = o2 instanceof NodeInv ? 1 : 0; if (val1 == val2) { return super.compare(o1, o2); } return val1 - val2; } }
/** * @return all distinct outgoing edges to children of the given node type */ public SortedSet<Node> getEdges(NodeType nodeType) { SortedSet<Node> edges = new TreeSet<>(new NodeComparator()); for (Entry<Node, List<RDFResourceTree>> entry : edge2Children.entrySet()) { Node edge = entry.getKey(); List<RDFResourceTree> children = entry.getValue(); for (RDFResourceTree child : children) { if ((nodeType == NodeType.LITERAL && child.isLiteralNode()) || (nodeType == NodeType.RESOURCE && child.isResourceNode())) { edges.add(edge); break; } } } return edges; }
(v1, v2) -> new NodeComparator().compare(v1, v2), (e1, e2) -> new NodeComparator().compare(e1.getEdge(), e2.getEdge())) .isomorphismExists(); if(isomorph) {
public static Map<Node, Set<Triple>> indexSorted(Iterable<Quad> quads) { Map<Node, Set<Triple>> result = new TreeMap<Node, Set<Triple>>(new NodeComparator()); for(Quad q : quads) { Set<Triple> triples = result.get(q.getGraph()); if(triples == null) { triples = new TreeSet<Triple>(new TripleComparator()); result.put(q.getGraph(), triples); } triples.add(q.asTriple()); } return result; }
@Override public int compareTo(RDFNodeTuple t) { NodeComparator comparator = new NodeComparator(); return ComparisonChain.start(). compare(a.asNode(), t.a.asNode(), comparator). compare(b.asNode(), t.b.asNode(), comparator). result(); }
@Override public int compareTo(RDFResourceTree other) { return ComparisonChain.start(). compare(this.getData(), other.getData(), new NodeComparator()). // root node compare(this.getNumberOfChildren(), other.getNumberOfChildren()). // number of direct children compare(QueryTreeUtils.toOWLClassExpression(this), QueryTreeUtils.toOWLClassExpression(other)). // class expression representation result(); }
private static SortedSet<Node> toSet(QuerySolution qs) { SortedSet<Node> nodes = new TreeSet<>(new NodeComparator()); ArrayList<String> vars = Lists.newArrayList(qs.varNames()); vars.forEach(var -> nodes.add(qs.get(var).asNode())); return nodes; }
public void init() { Set<Node> existentialMeaninglessProperties = new TreeSet<>(new NodeComparator()); try { List<String> lines = Files.readLines(new File(this.getClass().getClassLoader().getResource(PATH).toURI()), Charsets.UTF_8); for (String line : lines) { if(!line.trim().isEmpty() && !line.startsWith("#")) { existentialMeaninglessProperties.add(NodeFactory.createURI(line.trim())); } } } catch (IOException | URISyntaxException e) { e.printStackTrace(); } setExistentialMeaninglessProperties(existentialMeaninglessProperties); }
private static SortedSet<Node> toSet(QuerySolution qs) { SortedSet<Node> nodes = new TreeSet<>(new NodeComparator()); ArrayList<String> vars = Lists.newArrayList(qs.varNames()); vars.forEach(var -> nodes.add(qs.get(var).asNode())); return nodes; }
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException { child2Edge = new HashMap<>(); edge2Children = new TreeMap<>(new NodeComparator());
private void analyze() { Set<Node> existentialMeaninglessProperties = new TreeSet<>(new NodeComparator());
public void analyze(SparqlEndpointKS ks) { Set<Node> existentialMeaninglessProperties = new TreeSet<>(new NodeComparator());