This page describes a simple demo of using public product master data from the data set at
via the LOD Virtuoso repository at
via a simple Python script.
Click here for the video: http://www.ebusiness-unibw.org/mhepp/SemanticPOS2.mov
# Semantic Web Cash Register
# martin hepp, May 25, 2009
import urllib
import simplejson
print 'UniBW Munich Semantic Web-powered Point-Of-Sale'
print 'Written by the E-Business & Web Science Research Group'
=0
total
def fetchLabel(EanUpc):
= "SELECT ?label WHERE {?uri rdf:type <http://purl.org/goodrelations/v1#ProductOrServiceModel>."+\
query "?uri <http://purl.org/goodrelations/v1#hasEAN_UCC-13> \""+EanUpc+\
"\"^^<http://www.w3.org/2001/XMLSchema#string>. ?uri rdfs:label ?label}"
= urllib.urlencode({'default-graph-uri': '', 'query': query,
params 'format': 'application/sparql-results+json', 'debug' : 'on', 'timeout' : ''})
= urllib.urlopen("http://lod.openlinksw.com/sparql?%s" % params)
f
= simplejson.load(f)
results = results['results']
results = results['bindings']
results = results[0]
results = results['label']
results = results['value']
results return results
while True:
=raw_input('Enter EAN or scan item') # fetch EAN from keyboard
eanif (ean==''): break # stop when input is empty
="0"+ean
ean print ean # print EAN
= fetchLabel(ean) # get label from the Semantic Web
productname = 1.99 # get price per unit
price print productname, price # show product name and price
=total+price # add product price to bill
total
print 'Thanks for shopping with us. The total is', total