Semantic Point of Sale

From Wiki of the E-Business and Web Science Research Group
Jump to: navigation, search
GoodRelations is a standardized vocabulary for product, price, and company data that can be embedded into existing static and dynamic Web pages.

Project Main Page
Developer's Wiki
GoodRelations Cookbook

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.


Picture 1.png

Click here for the video:


# 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'


def fetchLabel(EanUpc):
        query = "SELECT ?label WHERE {?uri rdf:type <>."+\
        "?uri <> \""+EanUpc+\
        "\"^^<>. ?uri rdfs:label ?label}"
        params = urllib.urlencode({'default-graph-uri': '', 'query': query,
       'format': 'application/sparql-results+json', 'debug' : 'on', 'timeout' : ''})
        f = urllib.urlopen("" % params)
        results = simplejson.load(f)
        results = results['results']
        results = results['bindings']
        results = results[0]
        results = results['label']
        results = results['value']
        return results
while True:
    ean=raw_input('Enter EAN or scan item')  # fetch EAN from keyboard
    if (ean==''): break             # stop when input is empty
    ean ="0"+ean 
    print ean                       # print EAN
    productname = fetchLabel(ean)   # get label from the Semantic Web
    price = 1.99                    # get price per unit
    print productname, price        # show product name and price
    total=total+price               # add product price to bill

print 'Thanks for shopping with us. The total is', total