Advertisement
asanchez75

python/rdflib/materialization

Oct 14th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. from rdflib import Graph
  2.  
  3. g = Graph()
  4. g.parse("example.ttl", format="turtle")
  5. qres = g.query(
  6. """CONSTRUCT {?s rdfs:subClassOf ?o}
  7. {
  8. ?s rdfs:subClassOf* ?o.
  9. FILTER (?s != ?o)
  10. } """)
  11.  
  12. for s, p, o in qres:
  13. g.add((s,p,o))
  14.  
  15. g.serialize(destination='example.ttl', format='turtle')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement