本文整理汇总了Python中rdflib.graph.Graph.templateMap方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.templateMap方法的具体用法?Python Graph.templateMap怎么用?Python Graph.templateMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rdflib.graph.Graph
的用法示例。
在下文中一共展示了Graph.templateMap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import templateMap [as 别名]
#.........这里部分代码省略.........
print(p.identifier, first(p.label))
print(repr(p))
for c in AllClasses(cGraph):
if options.normalize:
if c.isPrimitive():
primAnc = [sc for sc in c.subClassOf if sc.isPrimitive()]
if len(primAnc) > 1:
warnings.warn("Branches of primitive skeleton taxonomy" +
" should form trees: %s has %s primitive parents: %s" % (
c.qname, len(primAnc), primAnc), UserWarning, 1)
children = [desc for desc in c.subSumpteeIds()]
for child in children:
for otherChild in [o for o in children if o is not child]:
if not otherChild in [c.identifier
for c in Class(child).disjointWith]: # and\
warnings.warn("Primitive children (of %s) " % (c.qname) +
"must be mutually disjoint: %s and %s" % (
Class(child).qname,
Class(otherChild).qname), UserWarning, 1)
# if not isinstance(c.identifier,BNode):
print(c.__repr__(True))
if not options.why:
#Naive construction of graph
for rule in ruleSet:
network.buildNetworkFromClause(rule)
magicSeeds=[]
if options.why:
builtinTemplateGraph = Graph()
if options.builtinTemplates:
builtinTemplateGraph = Graph().parse(options.builtinTemplates,
format='n3')
factGraph.templateMap = \
dict([(pred, template)
for pred, _ignore, template in
builtinTemplateGraph.triples(
(None,
TEMPLATES.filterTemplate,
None))])
goals = []
query = ParseSPARQL(options.why)
network.nsMap['pml'] = PML
network.nsMap['gmp'] = GMP_NS
network.nsMap['owl'] = OWL_NS
nsBinds.update(network.nsMap)
network.nsMap = nsBinds
if not query.prolog:
query.prolog = Prolog(None, [])
query.prolog.prefixBindings.update(nsBinds)
else:
for prefix, nsInst in list(nsBinds.items()):
if prefix not in query.prolog.prefixBindings:
query.prolog.prefixBindings[prefix] = nsInst
goals.extend([(s, p, o) for s, p, o, c in ReduceGraphPattern(
query.query.whereClause.parsedGraphPattern,
query.prolog).patterns])
# dPreds=[]# p for s,p,o in goals ]
magicRuleNo = 0
bottomUpDerivedPreds = []
# topDownDerivedPreds = []
defaultBasePreds = []
defaultDerivedPreds = set()
hybridPredicates = []
mapping = dict(newNsMgr.namespaces())
for edb in options.edb: