Delete triples from graph?

8 views
Skip to first unread message

Leif Warner

unread,
Jan 3, 2011, 4:53:39 PM1/3/11
to scardf
Would it be much work to add delete functionality to the graph store?

I've been using straight scardf for development, and I think I was
planning on going with the Jena backing in production, anyways, for
things like inferencing and SPARQL.

For the jena wrapper just adding a pass-through to the jena method
works:
def remove( t: RdfTriple ) = m remove statement( t )

I ran up against this while trying to re-run some augmentation
rules... I wanted to port some work on an open-source community
directory here in town to a semantic web stack. I was using RDFa as a
templating language, and for that, data should be in triples (as much
as possible)
On the home page,
http://epdx.org/
it shows the count in each class of resource.
I was thinking something like
Augment add {n=> n -count-> ( n.graph/-/having(RDF.Type -> n) size )}
forEach {_/-/having(RDF.Type -> OWL.Class)} on graph
could work to provide that information.
But after an update, that rule would need to get ran again, and the
old value should be deleted... The augmentations could be kept in a
new graph, and that graph dropped and regenerated after every update?
The "on()" method of AugPreparator only seems to offer to add the
triples to the same graph. Should there be something in there, like a
"from()" method, that would only return the augmentations, or should I
just construct the augmenter directly, like
new SnBagAugmenter({_/-/having(RDF.Type -> OWL.Class)},
List({n:GraphNode=> n -count-> ( n.graph/-/having(RDF.Type -> n)
size )})) augmentations graph

I imagine I might want to write some Jena rule for this also, when I
figure out how...
-Leif

Hrvoje Simic

unread,
Jan 4, 2011, 11:19:26 AM1/4/11
to sca...@googlegroups.com
> Would it be much work to add delete functionality to the graph store?

I don't know much about the theory of deleting and updating RDF
triples to figure out the best design, but I guess it would be
relatively straightforward. But see below.

> I was thinking something like
> Augment add {n=> n -count-> ( n.graph/-/having(RDF.Type -> n) size )}
> forEach {_/-/having(RDF.Type -> OWL.Class)} on graph

Nice augmentation :) Feels kinda weird to see someone else writing
these crazy expressions.

> But after an update, that rule would need to get ran again, and the
> old value should be deleted...  The augmentations could be kept in a
> new graph, and that graph dropped and regenerated after every update?
> The "on()" method of AugPreparator only seems to offer to add the
> triples to the same graph.

Actually, it executes "g ++ augmentations( g )". The "++" method is
inconsistent: while for immutable implementations it returns a new
graph, for MutableSetGraph and JenaGraph it mutates the collection.
Since Scala 2.8 collection library sets up a convention of using "++="
method for mutating state and "++" for leaving the collection
unchanged, I'm planning to fix this.

> Should there be something in there, like a
> "from()" method, that would only return the augmentations, or should I
> just construct the augmenter directly, like
> new SnBagAugmenter({_/-/having(RDF.Type -> OWL.Class)},
> List({n:GraphNode=> n -count-> ( n.graph/-/having(RDF.Type -> n)
> size )})) augmentations graph

There should be multiple methods, but the syntax is kinda messed up at
the moment. Maybe you could throw a couple of your expressions like
this so we could flesh out the most readable (DSL-ish) API. I guess
there are three cases:

- augmentations only
- graph expanded to include augmentations
- copy of the graph, expanded to include augmentations

Hrvoje Simic

unread,
Jan 7, 2011, 8:14:11 AM1/7/11
to sca...@googlegroups.com
> The "++" method is
> inconsistent: while for immutable implementations it returns a new
> graph, for MutableSetGraph and JenaGraph it mutates the collection.
> Since Scala 2.8 collection library sets up a convention of using "++="
> method for mutating state and "++" for leaving the collection
> unchanged, I'm planning to fix this.

Fixed in r204, r205.

http://code.google.com/p/scardf/source/detail?r=204

There is a loose end with predicate trees, which will be fixed soon.

Leif Warner

unread,
Feb 22, 2011, 12:55:29 AM2/22/11
to scardf
Maybe "from" to generate a new graph containing the augmented triples,
and "to" to modify the existing graph in place? ("of"?)

Also, the documentation wiki page on graph Augmentation could use a
mention that the augmentation needs to end with something like "on
graph"; it seems to leave that part out.
Right now, with the latest svn build, running something like
Augment add {n=> n -count-> ( n.graph/-/having(RDF.Type -> n) size )}
forEach {_/-/having(RDF.Type -> OWL.Class)} on model
on a wrapped Jena Model (JenaGraph) leaves the existing graph
unchanged, but returns a copy of the entire graph plus the triples
generated from the augmentation. Would there be a method for
modifying the existing graph in-place, or a convenience syntax for
only returning the generated triples, to be manually added to the
existing graph?
-Leif
Reply all
Reply to author
Forward
0 new messages