简体   繁体   English

如何从Java读取RDF Freebase概念?

[英]How to read from Java a RDF freebase concept?

I would like to read a freebase dump like this from Java: 我想从Java读取这样的freebase转储:

http://rdf.freebase.com/ns/m.0cycc http://rdf.freebase.com/ns/m.0cycc

I tried to read it from Jena using the following code: 我尝试使用以下代码从Jena读取它:

    OntModel om = ModelFactory.createOntologyModel();
    om.read(freebaseURL, "N3");

But I got an Exception: 但是我有一个例外:

org.apache.jena.riot.RiotException: [line: 34, col: 37] illegal escape sequence value: x (0x78) org.apache.jena.riot.RiotException:[行:34,列:37]非法转义序列值:x(0x78)

Is there a way to.. 有办法吗..

a) automatically escape these characters? a)自动转义这些字符? (I found this post, but it seems to be a manual solution, and I need an automatic one: How to read Freebase RDF data? It seems to be a bit broken ) (我找到了这篇文章,但这似乎是一个手动的解决方案,并且我需要一个自动的解决方案: 如何读取Freebase RDF数据?它似乎有点破损

or 要么

b) read the file content using some other API? b)使用其他API读取文件内容? At the end I want to obtain some concrete values. 最后,我想获得一些具体的价值。 I think that I can develop a parsing algorithm for this kind of file structure, but if something is already done.. 我认为我可以为这种文件结构开发一种解析算法,但是如果已经完成的话。

Thanks 谢谢

I've created a code that "fix" my current problems. 我创建了一个代码来“解决”当前问题。 Probably this is not an universal fix (in fact, my fix is adapted to my needs, and in this case the fix makes that some content will be lost.. but for me is ok at this moment). 可能这不是通用修复程序(实际上,我的修复程序适合我的需要,在这种情况下,该修复程序会使某些内容丢失。.但是对于我而言,现在还可以)。

I attach a link to the code: 我在代码上附加了一个链接:

https://github.com/alejandrorg/VariousCodes/blob/master/FreebaseFixer.java https://github.com/alejandrorg/VariousCodes/blob/master/FreebaseFixer.java

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM