Skip to content
This repository was archived by the owner on Oct 8, 2020. It is now read-only.

Commit 86638b6

Browse files
More triple pattern utils
1 parent be9baec commit 86638b6

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

  • sansa-inference-common/src/main/scala/net/sansa_stack/inference/utils

sansa-inference-common/src/main/scala/net/sansa_stack/inference/utils/TripleUtils.scala

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package net.sansa_stack.inference.utils
22

3-
import org.apache.jena.graph.{Node, NodeFactory, Triple}
3+
import org.apache.jena.graph.{Node, NodeFactory, Node_Variable, Triple}
44
import org.apache.jena.reasoner.TriplePattern
55
import org.apache.jena.vocabulary.{OWL2, RDF, RDFS}
66
import org.apache.jena.vocabulary.OWL2._
@@ -97,6 +97,26 @@ object TripleUtils {
9797
}
9898
node
9999
}
100+
101+
/**
102+
* @return all nodes of the triple pattern
103+
*/
104+
def nodes(): Seq[Node] = {
105+
var nodes: Seq[Node] = Seq()
106+
107+
nodes +:= tp.getSubject
108+
nodes +:= tp.getPredicate
109+
nodes +:= tp.getObject
110+
111+
nodes
112+
}
113+
114+
/**
115+
* @return all var nodes of the triple pattern
116+
*/
117+
def vars(): Seq[Node] = {
118+
nodes.filter(_.isVariable)
119+
}
100120
}
101121

102122
}

0 commit comments

Comments
 (0)