RDFLib空白节点打印 [英] RDFLib Blank Node Printing

查看:173
本文介绍了RDFLib空白节点打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个RDF数据集,其中三元组以N-Triples格式存储,如下所示:

I have an RDF dataset where triples are stored in N-Triples format like follows:

<http://ebola.ndssl.bi.vt.edu/country/1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://ebola.ndssl.bi.vt.edu/vocab/country> .
_:AmapX3aXcountryX5fXcountryX5fXnameX5fXclassMapX40XX40X1 <http://ebola.ndssl.bi.vt.edu/vocab/hasValue> "Guinea" .

我想对空白节点进行一些处理.我正在编写一个程序以使用Python读取此文件.我正在使用Python RDFLib库.读取文件后,我将打印其内容.但是,问题在于空白节点名称的输出方式不同.例如:

I want to do some processing with the blank nodes. I am writing a program to reading this file in Python. I am using Python RDFLib library. After reading the file, I print its content. However, the problem is blank node name is coming out differently. For example:

_:AmapX3aXcountryX5fXcountryX5fXnameX5fXclassMapX40XX40X1
 is showing like following
N75424221e7df43708c3e2a135e3e888b

我需要原始RDF文件空白节点名称,如下所示:

I need original RDF file blank node name as follows:

_:AmapX3aXcountryX5fXcountryX5fXnameX5fXclassMapX40XX40X1

如何打印原始RDF文件的空白节点名称?

How can I print original RDF file blank node name?

推荐答案

您(可能)不能.空白节点ID对于它们所在的特定文件而言是本地的,不能保证在不同的序列化之间保留它们. RDFLib只需将ID替换为其自己的新内部ID.

You (probably) can't. Blank node ids are local to the specific file they are in, they're not guaranteed preserved between different serializations. RDFLib simply replaces the id with its own new internal id.

某些工具具有解析器设置,可以选择保留节点ID.我不知道RDFLib是否支持此功能,即使它支持:除非您有一个非常特定的用例,否则您不应该依赖保留的空白节点ID.由于某些原因,它们被称为空白:它们的ID出于所有意图和目的都是未知的".

Some tools have a parser setting to optionally preserve node ids. I don't know if RDFLib supports this, but even if it does: unless you have a very specific use case you should not be relying on blank node ids being preserved. They are called blank for a reason: their id is for all intents and purposes "unknown".

这篇关于RDFLib空白节点打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆