0

I am trying to replicate the example code in https://developers.google.com/freebase/v1/rdf-overview#rdf-documentation to obtain the RDF for a particular topic and store the result in rdflib. After setup, the url is https://www.googleapis.com/freebase/v1/rdf/m/02h40lc?key=XXXXX. However, upon running the code, I get the following error:

    "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;

etc., with the last line being:

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

The actual last line of the file is:

    rdfs:label    "Inglise keel"@et.

Have I missed some steps in getting the example to work? Thanks!

user1748083
  • 137
  • 6

1 Answers1

0

Looks like the parser doesn't like embedded periods/dots (.) in the prefixed URIs.

As a workaround, you can expand the ns: & key: prefixed URIs by hand before feeding them to the RDF parser (yes, that kind of defeats the whole point of using a standard parser). The results should look like this (which I think will parse):

  @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>;
Tom Morris
  • 10,490
  • 32
  • 53
  • Thanks Tom. I was hoping to use Python libraries load the (or a portion of the) RDF dump from Freebase into rdflib for some preliminary processing. It appears as if there is no straightforward way of doing so if I have to handcraft the input files to the parser. I'm curious to know how you and others have approached the problem. – user1748083 May 20 '13 at 21:43
  • I don't work with the dumps that much, but when I do, I tend to use zgrep, cut, and other Unix command line tools as opposed to RDF tools. The transformation that I'm describing would be a couple minutes work with sed, awk, or Python, so shouldn't really be that onerous (although I agree it shouldn't be necessary). – Tom Morris May 23 '13 at 01:58