本文整理汇总了Python中rdflib.graph.Graph.label方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.label方法的具体用法?Python Graph.label怎么用?Python Graph.label使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rdflib.graph.Graph
的用法示例。
在下文中一共展示了Graph.label方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle
# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import label [as 别名]
def handle(self, *args, **options):
from rdflib.graph import Graph
from rdflib import RDFS, RDF, OWL
from rdflib.term import URIRef, BNode, Literal
import yaml
OboDefinition = URIRef('http://purl.obolibrary.org/obo/IAO_0000115')
part_of_some = URIRef('http://purl.obolibrary.org/obo/BFO_0000050_some')
Synonym = URIRef(u'http://www.geneontology.org/formats/oboInOwl#hasSynonym')
g = Graph()
g.parse(args[1], 'xml')
Model = MuscleOwl if args[0] == 'm' else BehaviorOwl
# first pass, add the things
for subject in nonblankthings(g, g.subjects()):
slabel = g.label(subject)
m = get_model_instance(Model, unicode(subject))
m.uri = unicode(subject)
m.label = unicode(slabel)
m.rdfs_is_class = (subject, RDF.type, OWL.Class) in g
m.obo_definition = unicode(g.value(subject, OboDefinition, None))
m.rdfs_comment = unicode(g.value(subject, RDFS.comment, None))
synonyms = [unicode(syn) for syn in g.objects(subject, Synonym)]
if len(synonyms):
m.synonyms_comma_separated = ", ".join(synonyms)
else:
m.synonyms_comma_separated = None
m.save()
# second pass, add the relationships
for subject in nonblankthings(g, g.subjects()):
slabel = g.label(subject)
m = Model.objects.get(uri=unicode(subject))
m.rdfs_subClassOf_ancestors.clear()
# add all super-classes to m.rdfs_subClassOf_ancestors
for obj in nonblankthings(g, g.transitive_objects(subject, RDFS.subClassOf)):
if obj != subject:
a = Model.objects.get(uri=unicode(obj))
m.rdfs_subClassOf_ancestors.add(a)
m.bfo_part_of_some.clear()
# add all things that this thing is part of to m.bfo_part_of_some
for obj in nonblankthings(g, g.objects(subject, part_of_some)):
if obj != subject:
a = Model.objects.get(uri=unicode(obj))
m.bfo_part_of_some.add(a)
# add only direct super-classes to m.rdfs_subClassOf
#for obj in nonblankthings(g, g.objects(subject, RDFS.subClassOf)):
# if obj != subject:
# a = Model.objects.get(uri=unicode(obj))
# m.rdfs_subClassOf.add(a)
m.save()
示例2: Exception
# 需要导入模块: from rdflib.graph import Graph [as 别名]
# 或者: from rdflib.graph.Graph import label [as 别名]
if covar == NIDM_INDEPENDENT_ERROR:
covar = ""
else:
if covar_spatial == NIDM_SPATIALLY_LOCAL_MODEL:
covar_spatial = "local"
elif covar_spatial == NIDM_SPATIALLY_GLOBAL_MODEL:
covar_spatial = "global"
elif covar_spatial == NIDM_SPATIALLY_REGULARIZED_MODEL:
covar_spatial = "spatially regularized"
else:
raise Exception(
'Unknown spatial variance estimation: ' +
str(covar_spatial))
covar = " and a " + covar_spatial + " " + \
owl_graph.label(covar)
if drift_model:
drift_model = "Drift was fit with a " + \
owl_graph.label(drift_model).lower()
if spm_drift_cutoff:
drift_model = drift_model + \
" (" + spm_drift_cutoff + "s cut-off)."
if fsl_drift_cutoff:
drift_model = drift_model + \
" (" + fsl_drift_cutoff + "s FWHM)."
else:
drift_model = ""
print "-------------------"
print "%s-level analysis was performed with %s (version %s). \