面向python的语义web和rdf库
pymantic的Python项目详细描述
快速启动
>>> from __future__ import print_function >>> from pymantic.rdf import * >>> from pymantic.parsers import turtle_parser >>> import requests >>> Resource.prefixes['foaf'] = Prefix('http://xmlns.com/foaf/0.1/') >>> graph = turtle_parser.parse(requests.get('https://raw.github.com/norcalrdf/pymantic/master/examples/foaf-bond.ttl').text) >>> bond_james = Resource(graph, 'http://example.org/stuff/Bond') >>> print("%s knows:" % (bond_james.get_scalar('foaf:name'),)) >>> for person in bond_james['foaf:knows']: print(person.get_scalar('foaf:name'))
要求
pymantic需要Python2.7或更高版本。 lark用于Turtle和Ntriples解析器。 ^ {TT3}$库用于HTTP请求和SPARQL客户端。 {TT4} $和^ {TT5}$也是SPARQL客户端所需要的。
安装
$ pip install pymantic
这将安装pymantic及其所有依赖项。
文档
生成文档的本地副本需要sphinx:
$ pip install Sphinx