0

我正在尝试复制https://developers.google.com/freebase/v1/rdf-overview#rdf-documentation中的示例代码,以获取特定主题的 RDF 并将结果存储在 rdflib 中。设置后,网址为 https://www.googleapis.com/freebase/v1/rdf/m/02h40lc?key=XXXXX。但是,在运行代码时,我收到以下错误:

    "BadSyntax: at line 7 of <>:
     Bad syntax (EOF found in middle of path syntax) at ^ in:
     "@prefix key: <http://rdf.freebase.com/key/>.
      @prefix ns: <http://rdf.freebase.com/ns/>.
      @prefix owl: <http://www.w3.org/2002/07/owl#>.
      @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
      @prefix xsd: <http://www.w3.org/2001/XMLSchema#>.

      ns:m.02h40lc
          ns:base.database.database_topic.database_s_for_this_topic    ns:m.0861s;
          ns:base.rosetta.languoid.document    ns:m.05tq40j;
          ns:base.rosetta.languoid.document    ns:m.05tqsrm;

等等,最后一行是:

        rdfs:label    "Inglise keel"@et^..."

文件的实际最后一行是:

    rdfs:label    "Inglise keel"@et.

我是否错过了使示例正常工作的一些步骤?谢谢!

4

1 回答 1

0

看起来解析器不喜欢前缀 URI 中嵌入的句点/点 (.)。

作为一种解决方法,您可以在将它们提供给 RDF 解析器之前手动扩展 ns: & key: 前缀的 URI(是的,这会破坏使用标准解析器的全部意义)。结果应该是这样的(我认为会解析):

  @prefix key: <http://rdf.freebase.com/key/>.
  @prefix ns: <http://rdf.freebase.com/ns/>.

  <http://rdf.freebase.com/ns/m.02h40lc>
      <http://rdf.freebase.com/ns/base.database.database_topic.database_s_for_this_topic    <http://rdf.freebase.com/ns/m.0861s>;
      <http://rdf.freebase.com/ns/base.rosetta.languoid.document    <http://rdf.freebase.com/ns/m.05tq40j>;
于 2013-05-19T17:14:33.960 回答