#!/usr/bin/env python from rdflib import ConjunctiveGraph, Literal from lcsh.namespaces import LCSH, SKOS from sys import stdin g = ConjunctiveGraph('Sleepycat') g.open('store') try: for pref_label in stdin: pref_label = pref_label.rstrip() lccns = list(g.subjects(SKOS['prefLabel'], Literal(pref_label, 'en'))) print "%s [%s]" % (pref_label, ','.join(lccns)) finally: g.close()