-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
outE (out edges) and inE (in edges) methods #62
base: master
Are you sure you want to change the base?
Conversation
Motivation: import rdf from 'rdf-ext'
import clownface from 'clownface'
const ns = {
ex: rdf.namespace('http://example.org/'),
}
const dataset = rdf.dataset()
dataset.addAll([
rdf.quad(ns.ex.bob, ns.ex.exoticProperty, rdf.literal('Bob')),
rdf.quad(ns.ex.exoticProperty, ns.ex.label, rdf.literal('First name')),
])
const bob = clownface({ dataset: dataset })
.namedNode(ns.ex.bob)
// What's the label of exoticProperty?
console.log(bob.outE(ns.ex.exoticProperty).out(ns.ex.label).value)
// outputs 'First name' |
I support this effort, albeit I have not looked closely yet. That said, the motivation does not give it justice. What you describe can simply be done as -bob.outE(ns.ex.exoticProperty).out(ns.ex.label).value
+bob.node(ns.ex.exoticProperty).out(ns.ex.label).value What is missing, and came up a bunch of times, is to discover properties of // will return pointer to ex:exoticProperty
const properties = bob.outE() |
As it is, we can also use it to discover the properties of bob I agree that that is the best use case. import rdf from 'rdf-ext'
import clownface from 'clownface'
const ns = {
ex: rdf.namespace('http://example.org/'),
}
const dataset = rdf.dataset()
dataset.addAll([
rdf.quad(ns.ex.bob, ns.ex.exoticProperty, rdf.literal('Bob')),
rdf.quad(ns.ex.exoticProperty, ns.ex.label, rdf.literal('First name')),
rdf.quad(ns.ex.bob, ns.ex.age, rdf.literal(99)),
])
const bob = clownface({ dataset: dataset })
.namedNode(ns.ex.bob)
console.log(bob.outE().values)
// Outputs
// [ 'http://example.org/exoticProperty', 'http://example.org/age' ] |
In the RDF world, the term edge is not used that much. predicate and property are more common, where predicate is used in the context of triples and property in a higher level context. property is therefore the better choice for clownface. prop has already become a synonym for property for software developers. That would be in balance of having a short method name, but still one with a speaking name. -> E should be replaced with prop |
@bergos, the property is renamed. |
The |
Hi,
I was trying to 'follow my nose' and explore properties and objects using clownface, but it was difficult for me to explore 'properties' (for example, to get the label of a property)
I added the outE (out edges) and inE (in edges) methods to experiment. I find them useful.
This is the inspiration: https://github.com/mpollmeier/gremlin-scala/blob/master/gremlin-scala/src/test/scala/gremlin/scala/ArrowSyntaxSpec.scala
I made this pull request to discuss the addition of these two functions