【问题标题】:How to convert a Trig file to a Turtle file so that i can upload it in Sesame?如何将 Trig 文件转换为 Turtle 文件以便在 Sesame 中上传?
【发布时间】:2014-11-22 21:25:23
【问题描述】:
{
    ex:repository ex:createdBy ex:repOwner; ex:title “Rep_1”.

}
ex:books 
{
    ex:book_1 a ex:Science; ex:size “100”; ex:title “Science book 1”.
    ex:book_2 a ex:Science; ex:size “1000”; ex:title “Science book 2”. 
    ex:book_3 a ex:Fantasy; ex:size “100”; ex:title “Fantasy book 1”.
}

【问题讨论】:

  • I实际上你只需要把它格式化成Trig格式,因为Sesame支持Trig格式
  • 您的问题格式不正确。您能否尝试编辑您的问题,以便更清楚您的目标是什么?

标签: sesame turtle-rdf


【解决方案1】:

无需将 TriG 文件转换为 Turtle 即可将其上传到 Sesame,因为 Sesame 支持 TriG 格式。

此外,从 TriG 到 Turtle 的转换会丢失数据:TriG 是一种可以记录 quads 的格式,因此您可以将多个命名图形放在一个文件中,而 Turtle 只能记录三倍。如果将 TriG 转换为 Turtle,则会删除所有命名的图形信息。

话虽如此,在 Sesame 中从一种格式转换为另一种格式很简单:

// writing to System.out as an example, change to a fileoutputstream to write to file
RDFWriter turtleWriter = Rio.createWriter(RDFFormat.TURTLE, System.out);
RDFParser trigParser = Rio.createParser(RDFFormat.TRIG);

// link the parser with the writer
trigParser.setRDFHandler(turtleWriter);

File trigFile = new File("/path/to/file.trig");

trigParser.parse(new FileInputStream(trigFile), trigFile.getAbsolutePath()); 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-18
    • 2016-11-10
    • 2016-08-10
    • 1970-01-01
    • 2015-07-08
    • 1970-01-01
    • 2021-12-16
    • 2014-12-24
    相关资源
    最近更新 更多