Skip to content

Instantly share code, notes, and snippets.

View edsu's full-sized avatar

Ed Summers edsu

View GitHub Profile
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rda: <http://RDVocab.info/Elements/> .
@prefix dct: <http://purl.org/dc/terms/> .
@prefix lcsh: <http://id.loc.gov/authorities/> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix ex: <http://example.org/coordination#> .
<http://lccn.heroku.com/36029351#i>
rda:titleProper "Charlotte Temple" ;
dct:subject [
#!/usr/bin/env python
import sys
import urlparse
import robotparser # yes it's part of the python core!
try:
ua, url = sys.argv[0:2]
except:
print "usage: crawlable googlebot http://example.com/awesome.html"
@edsu
edsu / urls.py
Created November 20, 2009 20:49
from routes import Mapper
map = Mapper()
map.connect('book', '/book/{isbn}', controller='item', action='book')
map.connect('journal', '/journal/{issn}', controller='item', action='journal')
#!/usr/bin/env python
"""
Extract some RDF from O'Reilly's not well-formed Book Catalog RDFa.
"""
from rdflib.graph import ConjunctiveGraph
g = ConjunctiveGraph()
g.parse('http://oreilly.com/catalog/9780596516499/', format='rdfa', lax=True)
#!/usr/bin/env python
from rdflib.graph import ConjunctiveGraph
g = ConjunctiveGraph()
g.parse("http://inkdroid.org/journal/network", format='rdfa', lax=True)
g.parse("http://danbri.org/words/network", format='rdfa', lax=True)
for q in g.quads((None, None, None)):
print q
#!/usr/bin/env python
"""
Look for odd ampersands in URIs in O'Reilly data and print out the
context URI (where the assertions came from).
Output looks something like:
ed@inkdroid:~/bzr/oreilly-crawler$ ./amps.py
<http://oreilly.com/catalog/0636920001744/> a rdfg:Graph;rdflib:storage [a rdflib:Store;rdfs:label 'Sleepycat'].
<http://oreilly.com/catalog/9781593271749/> a rdfg:Graph;rdflib:storage [a rdflib:Store;rdfs:label 'Sleepycat'].
# generated with http://inkdroid.org/bzr/twitterator/friends.py
Adam from Twibes [twibes]
Felicity Barringer [felicitybarr]
George Frink [gwfrink3]
Dharmishta Rood [Dharmishta]
Adina Levin [alevin]
Keith Dawson [kdawson]
Ann Handley [MarketingProfs]
Michael Kinsley [michaelkinsley]
ed@rorty:~/Projects/rdflib$ python setup.py nosetests --tests rdflib.graph
running nosetests
running egg_info
unrecognized .svn/entries format; skipping .
writing rdflib.egg-info/PKG-INFO
error: rdflib.egg-info/PKG-INFO: Permission denied
ed@rorty:~$ sudo python ez_setup.py
Downloading http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg
Processing setuptools-0.6c11-py2.6.egg
Copying setuptools-0.6c11-py2.6.egg to /usr/local/lib/python2.6/dist-packages
Removing setuptools 0.6c9 from easy-install.pth file
Adding setuptools 0.6c11 to easy-install.pth file
Installing easy_install script to /usr/local/bin
Installing easy_install-2.6 script to /usr/local/bin
Installed /usr/local/lib/python2.6/dist-packages/setuptools-0.6c11-py2.6.egg
Failed example:
print triples_to_n3(cg2-cg1)
Expected:
<http://example.org> <http://example.org/ns#rel> <http://example.org/b> .
<http://example.org> <http://example.org/ns#rel> _:cb1634787881 .
_:cb1634787881 <http://example.org/ns#label> "B" .
Got:
<http://example.org> <http://example.org/ns#rel> <http://example.org/b> .
<http://example.org> <http://example.org/ns#rel> _:cb8496374808470151721 .
_:cb8496374808470151721 <http://example.org/ns#label> "B" .