-1

How can I iterate through the Freebase RDF data dump with a streaming parser and print the title of each entity and it's type ( type/object/type ) in PHP?

For example with expat: http://se2.php.net/manual/en/book.xml.php

or the new XML reader functions: http://se2.php.net/manual/en/book.xmlreader.php

or anything else that is a streaming parser that will parse the Freebase RDF data dump.

Community
  • 1
  • 1
Django Johnson
  • 1,383
  • 3
  • 21
  • 40
  • Am I mistaken or is this like the 5th StackOverflow question you've posted about exactly the same problem? It's perfectly fine to have no clue how to do something, but that's not an excuse to inundate SO with questions. Just hire someone who can figure it out - freelancer.com (if there is such a site) or whatever other favorite freelancers' site you like. It's not a programming question at this point. – Tom Morris Sep 24 '13 at 02:32

1 Answers1

2

You really don't need a streaming XML parser. The Freebase RDF data dumps are not XML, they're N-Triples and they've been specially formatted so that you can split them apart on tabs. All you need to do is open the file, read it one line at a time and split each line on tabs.

Shawn Simister
  • 4,613
  • 1
  • 26
  • 31
  • Oh. I thought RDF was XML. Ah, okay. Awesome! Thank you, I'll split them apart at tabs! – Django Johnson Sep 24 '13 at 01:39
  • 1
    @DjangoJohnson [RDF is _not_ XML](http://stackoverflow.com/a/17052385/1281433), although it can be serialized in XML (in the RDF/XML format). However, the same RDF graph can be serialized in many different ways in RDF/XML, so XML-based “solutions” are brittle and non-portable. – Joshua Taylor Sep 24 '13 at 03:54