public class QueryTreeUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
EMPTY_QUERY_TREE_QUERY |
Constructor and Description |
---|
QueryTreeUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
asGraph(RDFResourceTree tree,
String baseIRI,
org.apache.jena.shared.PrefixMapping pm,
File outputFile)
Export the query tree as GraphML file.
|
static double |
getComplexity(RDFResourceTree tree)
Returns the complexity of the given query tree.
|
static <T,V extends GenericTree<T,V>> |
getDepth(GenericTree<T,V> tree)
Returns the depth of the query tree
|
static Set<org.apache.jena.graph.Node> |
getEdges(RDFResourceTree tree)
Returns the set of edges that occur in the given query tree, i.e.
|
static List<RDFResourceTree> |
getLeafs(RDFResourceTree tree)
Returns all nodes in the given query tree.
|
static Set<org.apache.jena.graph.Node> |
getNodeLabels(RDFResourceTree tree)
Returns all nodes labels in the given query tree.
|
static List<RDFResourceTree> |
getNodes(RDFResourceTree tree)
Returns all nodes in the given query tree.
|
static int |
getNrOfEdges(RDFResourceTree tree)
Returns the number of edges that occur in the given query tree, which
is obviously `n-1` where n is the number of nodes.
|
static int |
getNrOfNodes(RDFResourceTree tree)
Returns the number of nodes in the given query tree, i.e.
|
static <T,V extends GenericTree<T,V>> |
getPathsToLeafs(GenericTree<T,V> tree)
Returns all paths to leaf nodes.
|
static List<RDFResourceTree> |
getPathToRoot(RDFResourceTree tree,
RDFResourceTree node)
Returns the path from the given node to the root of the given tree, i.e.
|
static boolean |
isNonTrivial(RDFResourceTree tree,
Entailment entailment) |
static <N> boolean |
isSubsumedBy(QueryTree<N> tree1,
QueryTree<N> tree2)
Determines if tree1 is subsumed by tree2, i.e.
|
static boolean |
isSubsumedBy(RDFResourceTree tree1,
RDFResourceTree tree2)
Determines if tree1 is subsumed by tree2, i.e.
|
static boolean |
isSubsumedBy(RDFResourceTree tree1,
RDFResourceTree tree2,
AbstractReasonerComponent reasoner,
boolean typeNode)
Determines if tree1 is subsumed by tree2, i.e.
|
static boolean |
isSubsumedBy(RDFResourceTree tree1,
RDFResourceTree tree2,
Entailment entailment)
Determines if tree1 is subsumed by tree2, i.e.
|
static boolean |
isSubsumedBy(RDFResourceTree tree1,
RDFResourceTree tree2,
Entailment entailment,
AbstractReasonerComponent reasoner) |
static boolean |
isSubsumedBy(RDFResourceTree tree1,
RDFResourceTree tree2,
QueryTreeImpl.LiteralNodeSubsumptionStrategy strategy) |
static boolean |
isSubsumedBy(RDFResourceTree tree1,
RDFResourceTree tree2,
SPARQLReasoner reasoner)
Determines if tree1 is subsumed by tree2, i.e.
|
static boolean |
keepMostSpecificTypes(RDFResourceTree tree,
AbstractReasonerComponent reasoner)
Prune the rdf:type nodes such that only the most specific types remain w.r.t.
|
static RDFResourceTree |
materializePropertyDomains(RDFResourceTree tree,
AbstractReasonerComponent reasoner) |
static RDFResourceTree |
materializeTypes(RDFResourceTree tree,
AbstractReasonerComponent reasoner)
Adds all rdf:type statements to each node based on the domain and range of the edges as well as the subClassOf
relations between all existing types.
|
static String |
printPathToRoot(RDFResourceTree tree,
RDFResourceTree node)
Print the path from the given node to the root of the given tree, i.e.
|
static void |
prune(RDFResourceTree tree,
AbstractReasonerComponent reasoner,
Entailment entailment)
Remove trivial statements according to the given entailment semantics:
|
static void |
rebuildNodeIDs(RDFResourceTree tree)
Rebuilds the node IDs starting from the root node.
|
static boolean |
removeVarLeafs(RDFResourceTree tree)
Recursively removes edges that lead to a leaf node which is a variable.
|
static <N> boolean |
sameTrees(QueryTree<N>... trees)
Determines if the trees are equivalent from a subsumptional point of view.
|
static <N> boolean |
sameTrees(QueryTree<N> tree1,
QueryTree<N> tree2)
Determines if both trees are equivalent from a subsumptional point of
view.
|
static <N> boolean |
sameTrees(RDFResourceTree tree1,
RDFResourceTree tree2) |
static org.jgrapht.Graph<Vertex,Edge> |
toGraph(RDFResourceTree tree,
String baseIRI,
org.apache.jena.shared.PrefixMapping pm)
Convert the query tree to a directed labelled graph.
|
static org.apache.jena.rdf.model.Model |
toModel(RDFResourceTree tree) |
static org.apache.jena.rdf.model.Model |
toModel(RDFResourceTree tree,
org.apache.jena.rdf.model.Resource subject) |
static org.semanticweb.owlapi.model.OWLClassExpression |
toOWLClassExpression(RDFResourceTree tree) |
static org.semanticweb.owlapi.model.OWLClassExpression |
toOWLClassExpression(RDFResourceTree tree,
QueryTreeImpl.LiteralNodeConversionStrategy literalConversion) |
static org.apache.jena.query.Query |
toSPARQLQuery(RDFResourceTree tree)
Returns a SPARQL query representing the query tree.
|
static String |
toSPARQLQueryString(RDFResourceTree tree) |
static String |
toSPARQLQueryString(RDFResourceTree tree,
List<org.apache.jena.graph.Node> nodes2Select,
String baseIRI,
org.apache.jena.shared.PrefixMapping pm) |
static String |
toSPARQLQueryString(RDFResourceTree tree,
org.apache.jena.shared.PrefixMapping pm) |
static String |
toSPARQLQueryString(RDFResourceTree tree,
String baseIRI,
org.apache.jena.shared.PrefixMapping pm) |
static String |
toSPARQLQueryString(RDFResourceTree tree,
String baseIRI,
org.apache.jena.shared.PrefixMapping pm,
QueryTreeImpl.LiteralNodeConversionStrategy literalConversion,
List<org.apache.jena.graph.Node> nodes2Select) |
public static String EMPTY_QUERY_TREE_QUERY
public QueryTreeUtils()
public static void rebuildNodeIDs(RDFResourceTree tree)
tree
- the treepublic static List<RDFResourceTree> getPathToRoot(RDFResourceTree tree, RDFResourceTree node)
tree
- the query treenode
- the nodepublic static String printPathToRoot(RDFResourceTree tree, RDFResourceTree node)
tree
- the query treenode
- the nodepublic static int getNrOfNodes(RDFResourceTree tree)
tree
- the query treepublic static Set<org.apache.jena.graph.Node> getEdges(RDFResourceTree tree)
tree
- the query treepublic static int getNrOfEdges(RDFResourceTree tree)
tree
- the query treepublic static double getComplexity(RDFResourceTree tree)
c(T) = 1 + log(|U| * α + |L| * β + |VAR| * γ)
α, β, γ
being the weight of the particular node types.
tree
- the query treepublic static <N> boolean isSubsumedBy(QueryTree<N> tree1, QueryTree<N> tree2)
tree1
- tree2
- public static List<RDFResourceTree> getNodes(RDFResourceTree tree)
tree
- the query treepublic static Set<org.apache.jena.graph.Node> getNodeLabels(RDFResourceTree tree)
tree
- the query treepublic static List<RDFResourceTree> getLeafs(RDFResourceTree tree)
tree
- the query treepublic static <T,V extends GenericTree<T,V>> int getDepth(GenericTree<T,V> tree)
tree
- the query treepublic static boolean isSubsumedBy(RDFResourceTree tree1, RDFResourceTree tree2)
tree1
- the first query treetree2
- the second query treetree1
is subsumed by tree2
public static boolean isSubsumedBy(RDFResourceTree tree1, RDFResourceTree tree2, QueryTreeImpl.LiteralNodeSubsumptionStrategy strategy)
public static boolean isSubsumedBy(RDFResourceTree tree1, RDFResourceTree tree2, Entailment entailment)
tree1
- tree2
- entailment
- public static boolean isSubsumedBy(RDFResourceTree tree1, RDFResourceTree tree2, SPARQLReasoner reasoner)
tree1
- tree2
- public static boolean isSubsumedBy(RDFResourceTree tree1, RDFResourceTree tree2, AbstractReasonerComponent reasoner, boolean typeNode)
tree1
- tree2
- @SafeVarargs public static <N> boolean sameTrees(QueryTree<N>... trees)
trees
- public static <N> boolean sameTrees(QueryTree<N> tree1, QueryTree<N> tree2)
tree1
- tree2
- public static <N> boolean sameTrees(RDFResourceTree tree1, RDFResourceTree tree2)
public static org.apache.jena.rdf.model.Model toModel(RDFResourceTree tree)
public static org.apache.jena.rdf.model.Model toModel(RDFResourceTree tree, org.apache.jena.rdf.model.Resource subject)
public static org.semanticweb.owlapi.model.OWLClassExpression toOWLClassExpression(RDFResourceTree tree)
public static org.semanticweb.owlapi.model.OWLClassExpression toOWLClassExpression(RDFResourceTree tree, QueryTreeImpl.LiteralNodeConversionStrategy literalConversion)
public static org.apache.jena.query.Query toSPARQLQuery(RDFResourceTree tree)
SELECT ?s WHERE {?s ?p ?o.}
tree
- public static String toSPARQLQueryString(RDFResourceTree tree, List<org.apache.jena.graph.Node> nodes2Select, String baseIRI, org.apache.jena.shared.PrefixMapping pm)
public static String toSPARQLQueryString(RDFResourceTree tree)
public static String toSPARQLQueryString(RDFResourceTree tree, org.apache.jena.shared.PrefixMapping pm)
public static String toSPARQLQueryString(RDFResourceTree tree, String baseIRI, org.apache.jena.shared.PrefixMapping pm)
public static String toSPARQLQueryString(RDFResourceTree tree, String baseIRI, org.apache.jena.shared.PrefixMapping pm, QueryTreeImpl.LiteralNodeConversionStrategy literalConversion, List<org.apache.jena.graph.Node> nodes2Select)
public static org.jgrapht.Graph<Vertex,Edge> toGraph(RDFResourceTree tree, String baseIRI, org.apache.jena.shared.PrefixMapping pm)
tree
- the query treebaseIRI
- the base IRI used for rendering of the nodespm
- the prefixes used for rendering of the nodespublic static void asGraph(RDFResourceTree tree, String baseIRI, org.apache.jena.shared.PrefixMapping pm, File outputFile)
tree
- the query treebaseIRI
- (optional) base IRIpm
- (optional) prefix mappingoutputFile
- the output filepublic static RDFResourceTree materializePropertyDomains(RDFResourceTree tree, AbstractReasonerComponent reasoner)
public static RDFResourceTree materializeTypes(RDFResourceTree tree, AbstractReasonerComponent reasoner)
tree
- the query treereasoner
- the reasonerpublic static void prune(RDFResourceTree tree, AbstractReasonerComponent reasoner, Entailment entailment)
?s a ?x
tree
- the treeentailment
- the entailment regimepublic static boolean removeVarLeafs(RDFResourceTree tree)
tree
- the treepublic static boolean keepMostSpecificTypes(RDFResourceTree tree, AbstractReasonerComponent reasoner)
tree
- the treepublic static boolean isNonTrivial(RDFResourceTree tree, Entailment entailment)
public static boolean isSubsumedBy(RDFResourceTree tree1, RDFResourceTree tree2, Entailment entailment, AbstractReasonerComponent reasoner)
tree1
- tree2
- entailment
- reasoner
- public static <T,V extends GenericTree<T,V>> List<List<V>> getPathsToLeafs(GenericTree<T,V> tree)
T
- V
- tree
- the tree DL-Learner is licenced under the terms of the GNU General Public License.
Copyright © 2007-2019 Jens Lehmann