参考:https://www.cnblogs.com/bincoding/p/11223372.html 使用rdflib创建rdf文件
import rdflibdef create_rdf(): g = rdflib.Graph() # 实体 Pinganfu = rdflib.URIRef('http://www.example.org/Pinganfu') yiwaixian = rdflib.URIRef('http://www.example.org/yiwaixian') # 关系 price = rdflib.URIRef('http://www.example.org/price') product_from = rdflib.URIRef('http://www.example.org/from') # 属性 price_100 = rdflib.URIRef('http://www.example.org/100') price_200 = rdflib.URIRef('http://www.example.org/200') from_paic = rdflib.URIRef('http://www.example.org/paic') from_pajiankang = rdflib.URIRef('http://www.example.org/Pingan jiankangxian') g.add((Pinganfu,price,price_100)) g.add((yiwaixian,price_200)) g.add((Pinganfu,product_from,from_paic)) g.add((yiwaixian,from_pajiankang)) g.serialize("graph.rdf")if __name__ == "__main__": create_rdf()
jena fuseki导入生成的rdf文件,需要utf-8格式
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-Syntax-ns#>select *where { ?product <http://www.example.org/price> ?price .}
查询结果
jena数据格式
参考:
https://blog.csdn.net/Oeljeklaus/article/details/65436866
https://www.w3.org/TR/sparql11-query/#WritingSimpleQueries
以上是内存溢出为你收集整理的python使用rdflib创建rdf,在jena fuseki上执行SPARQL查询全部内容,希望文章能够帮你解决python使用rdflib创建rdf,在jena fuseki上执行SPARQL查询所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)