Created
January 19, 2012 22:10
-
-
Save colwilson/1643199 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
from sparql import DBpediaEndpoint | |
def main (): | |
s = DBpediaEndpoint() | |
resource_uri = "http://dbpedia.org/resource/Foobar" | |
results = s.query(""" | |
SELECT ?o | |
WHERE { <%s> dbpedia-owl:abstract ?o . | |
FILTER(langMatches(lang(?o), "EN")) } | |
""" % resource_uri) | |
abstract = results[0]["o"]["value"] | |
print abstract | |
if __name__ == '__main__': | |
try: | |
main() | |
sys.exit(0) | |
except KeyboardInterrupt, e: # Ctrl-C | |
raise e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment