Skip to content

Instantly share code, notes, and snippets.

@njh
Created June 30, 2010 10:57
Show Gist options
  • Save njh/458519 to your computer and use it in GitHub Desktop.
Save njh/458519 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'rack/test'
require 'erb'
require 'rdf/json'
require 'rdf/rdfxml'
require 'rdf/ntriples'
require 'rdf/rdfa'
base_uri = "http://dbpedialite.org/things/934787"
graph = RDF::Graph.new(base_uri)
RDF::Reader::for(:rdfa).new(DATA.read, :base_uri => base_uri) do |reader|
reader.each_statement do |statement|
graph << statement
end
end
p graph.size
__END__
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<head>
<title>dbpedia lite</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link type="text/css" rel="stylesheet" href="/stylesheet.css" />
<link rel="foaf:primaryTopic" href="http://dbpedialite.org/things/934787#thing" />
<link rel="alternate" type="application/rdf+xml" href="/things/934787.rdf" title="RDF/XML" />
<link rel="alternate" type="text/plain" href="/things/934787.nt" title="N-Triples" />
<link rel="alternate" type="application/json" href="/things/934787.json" title="JSON" />
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-15759799-2']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<div id="header">
<h1 id="title">About: <a href="http://dbpedialite.org/things/934787#thing">Ceres, Fife</a></h1>
<h2><a href="http://dbpedialite.org/things/934787#thing">http://dbpedialite.org/things/934787#thing</a></h2>
</div>
<div id="content">
<div id="map"></div>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAArv9G1BkO0gxnWS5UwgAUcxTpFJMlrih0EInfmgkti7-ZKQDRBRTphKY0sV9v8PuRfqpo9onlsV4ZPw" type="text/javascript"></script>
<script type="text/javascript">
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(56.293431,-2.970134), 13);
map.addControl(new GSmallMapControl());
}
</script>
<table id="description" about="http://dbpedialite.org/things/934787#thing">
<tr><th>Property</th><th>Value</th></tr>
<tr>
<td>rdfs:comment</td>
<td property="rdfs:comment"><p>Ceres is a village in Fife, Scotland, located in a small valley approximately 2 miles over the Ceres Moor from Cupar and 7 miles from St Andrews. The former parish of that name included the settlements of Baldinnie, Chance Inn, Craigrothie, Pitscottie and Tarvit Mill.</p><p>It is one of the most historic and picturesque villages in Scotland and one of the few Scottish villages to have a village green. Its most memorable feature is possibly the 19th century statue of "The Provost" at the Cross, which is in the form of a toby jug and is probably satirical.</p></td>
</tr>
<tr>
<td>geo:long</td>
<td property="geo:long">-2.970134</td>
</tr>
<tr>
<td>geo:lat</td>
<td property="geo:lat">56.293431</td>
</tr>
<tr>
<td>rdfs:label</td>
<td property="rdfs:label">Ceres, Fife</td>
</tr>
<tr>
<td>owl:sameAs</td>
<td><a href="http://rdf.freebase.com/ns/m.03rf2x" rel="owl:sameAs">http://rdf.freebase.com/ns/m.03rf2x</a></td>
</tr>
<tr>
<td>owl:sameAs</td>
<td><a href="http://dbpedia.org/resource/Ceres%2C_Fife" rel="owl:sameAs">http://dbpedia.org/resource/Ceres%2C_Fife</a></td>
</tr>
<tr>
<td>foaf:page</td>
<td><a href="http://en.wikipedia.org/wiki/Ceres%2C_Fife" rel="foaf:page">http://en.wikipedia.org/wiki/Ceres%2C_Fife</a></td>
</tr>
<tr>
<td>rdf:type</td>
<td><a href="http://www.w3.org/2002/07/owl#Thing" rel="rdf:type">http://www.w3.org/2002/07/owl#Thing</a></td>
</tr>
</table>
</div>
<div id="alternates">
<h4>Alternative formats:</h4>
<a href="/things/934787.rdf">RDF/XML</a> |
<a href="/things/934787.nt">N-Triples</a> |
<a href="/things/934787.json">JSON</a>
</div>
<div id="footer">
<div class="valid-badge" about=""
resource="http://www.w3.org/TR/rdfa-syntax"
rel="dc:conformsTo" xmlns:dc="http://purl.org/dc/terms/">
<a href="http://validator.w3.org/check?uri=referer"><img
src="/images/valid-xhtml-rdfa.png"
alt="Valid XHTML + RDFa" height="31" width="88" /></a>
</div>
<div class="links">
Powered by:
<a href="http://heroku.com/">heroku</a>,
<a href="http://www.sinatrarb.com/">Sinatra</a>,
<a href="http://github.com/bhuga/spira">Spira</a>,
<a href="http://rdf.rubyforge.org/">RDF.rb</a>,
<a href="http://nokogiri.org/">nokogiri</a>
</div>
<div class="links">
Source code: <a href="http://github.com/njh/dbpedialite">http://github.com/njh/dbpedialite</a>
</div>
</div>
</body>
</html>
@njh
Copy link
Author

njh commented Jun 30, 2010

/Library/Ruby/Gems/1.8/gems/nokogiri-1.4.2/lib/nokogiri/xml/node.rb:141: [BUG] Segmentation fault
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]

Abort trap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment