本文整理匯總了Python中Session.Session.add_assertion方法的典型用法代碼示例。如果您正苦於以下問題:Python Session.add_assertion方法的具體用法?Python Session.add_assertion怎麽用?Python Session.add_assertion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Session.Session
的用法示例。
在下文中一共展示了Session.add_assertion方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: breaks
# 需要導入模塊: from Session import Session [as 別名]
# 或者: from Session.Session import add_assertion [as 別名]
# Execute each sparql rule over until the number of new objects
# doesn't change. Once the total of objects stabilises, then the
# loop breaks (as rules can inference each other).
#
while currentObjs - initialObjs > 0:
initialObjs = currentObjs
for queryObj in orderOfService:
# if config print rule executuon
if Config.DEBUG > 0:
print "Executing query: " + queryObj[0]
res = rdf_session.sparql_query(queryObj[1], False)
# if config, print result
if Config.DEBUG > 0:
print ">>" + str(res)
if res:
for sub, pred, obj in res:
# add assertion
rdf_session.add_assertion([sub, pred, obj], queryObj[4], True)
# commit assertion
rdf_session.commit()
resList = []
currentObjs = rdf_session.store_sizes()[0]
rdf_session.commit()
currentObjs = rdf_session.store_sizes()[0]
# check sizes - how many new assertions
if Config.DEBUG > 0:
print str(initialObjs)
print str(currentObjs)