本文整理汇总了Python中rdflib.ConjunctiveGraph.__len__方法的典型用法代码示例。如果您正苦于以下问题:Python ConjunctiveGraph.__len__方法的具体用法?Python ConjunctiveGraph.__len__怎么用?Python ConjunctiveGraph.__len__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rdflib.ConjunctiveGraph
的用法示例。
在下文中一共展示了ConjunctiveGraph.__len__方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DeepGraphStore
# 需要导入模块: from rdflib import ConjunctiveGraph [as 别名]
# 或者: from rdflib.ConjunctiveGraph import __len__ [as 别名]
class DeepGraphStore():
store_name = 'SQLite'
def __init__(self, create=False, parse=None):
self.parse = parse
self.create = create
self.graph = None
def setUp(self):
self.path = "" + random_file_generating()
self.graph = Graph(store=self.store_name)
self.graph.open(self.path, create=self.create)
if self.create:
if not self.parse:
self.graph.parse("http://njh.me/foaf.rdf", format='xml')
else:
self.graph.parse(self.parse)
self.graph.commit()
def open(self, path):
self.graph = ConjunctiveGraph(self.store_name)
self.path = path
self.graph.open(self.path, create=False)
def query(self, sparql_query):
return self.graph.query(sparql_query)
def parse(self, path_to_file_):
self.graph.parse(path_to_file_)
def load(self, triples):
self.graph.load(triples)
def close(self):
self.graph.close()
def size(self):
size = self.graph.__len__()
size = len(self.graph)
# self.close()
return size