Using Rules with RDF
| Project: | Resource Description Framework (RDF) |
| Version: | 6.x-1.x-dev |
| Component: | Documentation |
| Category: | support request |
| Priority: | minor |
| Assigned: | Arto |
| Status: | postponed (maintainer needs more info) |
| Issue tags: | inference, rules integration |
I'm trying to build a set of basic Rules module's events, conditions and actions against the RDF/RDF Schema modules. It appears that hook_rdf() only gets called on insert and delete events when RDF data is manually inserted or deleted into the site.
hook_rdf also gets called with a strange (array) $op value when user performs an import operation, but that's a support request for another day.
Meanwhile, when one creates a node, the RDF data for that node is available when you query for it in the RDF Data content management page using the node URL as the Subject value.
What is the easiest way to create a "new RDF triple exists" and "RDF triple destroyed" event in Rules, for node, user, taxonomy, and other RDFified data in the database? Do I have to implement these using hook_node, hook_user, hook_taxonomy, etc for each data type present in the RDF Schema?
I rather enjoy coding and developing sites with Rules/Workflow_NG, and would like to create some basic reasoning functions using RDF. Basic reasoning is sort-of why semantic nets were invented in the first place. :)

#1
By hook_node, I mean hook_nodeapi. My bad.
#2
Mike, this is just a quick note to say that I will have a look more in-depth soon. I'm haven't used Rules previously but I will certainly help in any way I can. Reasoning support would be very welcome.
#3
Attached is a simple proof-of-concept RDF/Rules module called reasoner.module, which has some basic inference functions:
- an "insertion" event triggered by hook_rdf()
- an event triggered when a tuple is "inferred" by reasoner.module itself
- a condition that checks for a tuple existing in the store already
- an action to insert a tuple into the store
- an action to perform an rdf_query() and "infer" the result set
It's a fairly naive forward-chaining implementation, and I'm not sure what else to do with it, so have a copy.
#4
Bayesian inference across an RDF graph.
At least, I think I got the formula right. Also creates "supertuples" like (abc)(cde)=>(a(bd)e). Not very efficient, but it might be useful.
#5
Mike, are you still working on this stuff by any chance? I'd certainly recommend posting your code as a drupal.org project, I'm sure there would be interest from the community to take Drupal's RDF support in this direction.
#6
#7
Interesting.
#8
Wow. Very exciting.
@mgodfrey: This could be an awesome Google Summer of Code project.