{"id":58,"date":"2005-04-25T20:10:02","date_gmt":"2005-04-26T01:10:02","guid":{"rendered":"http:\/\/crschmidt.net\/blog\/?p=58"},"modified":"2005-04-25T20:10:02","modified_gmt":"2005-04-26T01:10:02","slug":"govtrack-rdf-data","status":"publish","type":"post","link":"https:\/\/crschmidt.net\/blog\/archives\/58\/govtrack-rdf-data\/","title":{"rendered":"GovTrack RDF Data"},"content":{"rendered":"<p>One of the larger sources of RDF data that I&#8217;ve loaded into a database, the <a href=\"http:\/\/www.govtrack.us\/\">GovTrack<\/a> RDF data is an interesting set with all kinds of information on congressmen adn so on. I recently started paying a bit more attention to the <a href=\"http:\/\/www.gargonza.com\">Gargonza Experiment<\/a>, and found a link to their data source via the <a href=\"http:\/\/rdf4food.asemantics.com\/\">wiki<\/a>.<\/p>\n<p>I&#8217;ve been playing with setting up SPARQL stuff all day, and have a couple simple pages set up from my new <a href=\"http:\/\/crschmidt.net\/semweb\/govtrack\/\">GovTrack<\/a> page. Loading the entire dataset (the RDF\/XML, at least: the n3 bits I left out for the time being) took a long time, and I did some tweaking of MySQL in the process to allow me to load data faster. Some things I learned, for optimizing loading time with Redland:<\/p>\n<p>1. MySQL&#8217;s key cache size is important when loading large data stores.<br \/>\n2. When loading statements, if you really want to optimize your load time, load with contexts. Redland will not check for duplicate statements in this case: This can be a major time saver. However, this may slow down later work, so it will probably not be worth it in the long term.<br \/>\n3. Loading into an already existing Redland database, even in a new model, will not increase speed: since Bnodes, Literals, and Resource tables are database wide, the selects to determine existing statements will still be just as slow as if you were loading into the existing models.<\/p>\n<p>I also discovered that my QueryResults->result() method was returning actual Redland nodes, rather than the wrapped Redland.php::Node. I suppose at one point I probably realized that, but it had slipped my mind. This made it really difficult to do things like deal with optionals: calling the librdf_node_to_string in the PHP bindings causes them to segfault if the node is NULL, and there&#8217;s no decent way to check if the node is null that I found.<\/p>\n<p>To compensate, I created a new way to create nodes (basically a copy constructor). This allowed me to check at node creation time whether it was a Resource\/Bnode\/Literal, which are the only types of Nodes there are. If it&#8217;s none of the above, I make it a PHP NULL, which I can check for, and it won&#8217;t crash PHP.<\/p>\n<p>I have learned the many different ways to segfault PHP over the past week working on Redland. Of course, they all relate to PHP doing funky things with a SWIG wrapper, but it&#8217;s still one of the more interesting experiences I&#8217;ve had.<\/p>\n<p>With the new PHP, all of the SPARQL interfaces I&#8217;ve got set up: one for <a href=\"http:\/\/crschmidt.net\/julie\/sparql\">Julie<\/a>, one for <a href=\"http:\/\/crschmidt.net\/semweb\/xtech\/sparql\">XTech<\/a>, one for <a href=\"http:\/\/crschmidt.net\/semweb\/govtrack\/sparql\">GovTrack<\/a> support Optionals. This has allowed me to create things like the GovTrack <a href=\"http:\/\/crschmidt.net\/semweb\/govtrack\/reps\">Senators page<\/a>, <small>(<a href=\"http:\/\/crschmidt.net\/semweb\/govtrack\/reps?state=nh\">example for New Hampshire<\/a>)<\/small>, listing some profile information about all the Senators from your state. (Representatives are more difficult. I&#8217;m still working on that.)<\/p>\n<p>Anyway, the GovTrack data is fun to play with, although I really need to develop some more interesting interfaces over the data. I plan to do that: just haven&#8217;t gotten there yet. These tools take time to develop, but they do feel really nifty. I would go into the why&#8217;s of why I feel it&#8217;s nifty, but I almost always end up feeling like a complete and utter geek when I do it, and it makes people look at me strange, so I&#8217;ll skip it this time.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the larger sources of RDF data that I&#8217;ve loaded into a database, the GovTrack RDF data is an interesting set with all kinds of information on congressmen adn so on. I recently started paying a bit more attention to the Gargonza Experiment, and found a link to their data source via the wiki. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28,4,29],"tags":[],"class_list":["post-58","post","type-post","status-publish","format-standard","hentry","category-php","category-redland-rdf-application-framework","category-sparql"],"_links":{"self":[{"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/posts\/58","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/comments?post=58"}],"version-history":[{"count":0,"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/posts\/58\/revisions"}],"wp:attachment":[{"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/media?parent=58"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/categories?post=58"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/tags?post=58"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}