#!/usr/bin/env python from calais import calais_graph, normalize from sys import argv from re import sub filename = argv[1] content = file(filename).read() g = calais_graph(content) sparql = """ PREFIX rdf: PREFIX ct: PREFIX cp: SELECT ?name WHERE { ?s rdf:type ct:Person . ?s cp:name ?name . } """ for row in g.query(sparql): print normalize(row[0])