本文整理汇总了Python中rdflib.URIRef.find方法的典型用法代码示例。如果您正苦于以下问题:Python URIRef.find方法的具体用法?Python URIRef.find怎么用?Python URIRef.find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rdflib.URIRef
的用法示例。
在下文中一共展示了URIRef.find方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fixit
# 需要导入模块: from rdflib import URIRef [as 别名]
# 或者: from rdflib.URIRef import find [as 别名]
def fixit(current_object, prefix_dictionary):
"""
Read the def data structure and replace all string URIs with URIRef entities
:param current_object: the piece of the data structure to be fixed
:return current_object: the piece repaired in place
"""
from rdflib import URIRef
if isinstance(current_object, dict):
for k in current_object.keys():
current_object[k] = fixit(current_object[k], prefix_dictionary)
elif isinstance(current_object, list):
for i in range(0, len(current_object)):
current_object[i] = fixit(current_object[i], prefix_dictionary)
elif isinstance(current_object, basestring):
if current_object.startswith("http://"):
current_object = URIRef(current_object)
elif current_object.startswith("xsd:"):
current_object = cast_to_rdflib(current_object)
elif ':' in current_object:
k = current_object.find(':')
tag = str(current_object[0:k + 1])
if tag in prefix_dictionary:
current_object = URIRef(str(current_object).replace(tag, prefix_dictionary[tag]))
return current_object