My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
dbpediaLiveExample  
Updated Nov 25, 2009 by cuu...@gmail.com

a Live dbpedia example

Introduction

use the DBPEDIA dump in a local store for better performance, this example uses the live DBPEDIA SPARQL endpoint

Details

import surf

store = surf.Store(reader = 'sparql_protocol',
                   endpoint = 'http://dbpedia.org/sparql',
                   default_graph = 'http://dbpedia.org')

print 'Create the session'
session = surf.Session(store, {})
session.enable_logging = False

PhilCollinsAlbums = session.get_class(surf.ns.YAGO['PhilCollinsAlbums'])

all_albums = PhilCollinsAlbums.all()

print 'Phil Collins has %d albums on dbpedia' % len(all_albums)

first_album = all_albums.first()
first_album.load()

print 'All covers'
for a in all_albums:
    if a.dbpedia_name:
        cvr = a.dbpedia_cover
        print '\tCover %s for "%s"' % (str(a.dbpedia_cover), str(a.dbpedia_name))

Sign in to add a comment
Powered by Google Project Hosting