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

Fetching Product Properties for Camcorders from the Semantic Web

This page describes a quick demo of how the Web of Data can be queried for product features for Camcorders.


PREFIX xsd: <>
PREFIX gr: <>
# show properties an property values for EAN "8714574993836"
SELECT ?p ?v ?uom WHERE
?uri rdf:type gr:ProductOrServiceModel.
?uri gr:hasEAN_UCC-13 "8714574993836"^^xsd:string.
?uri ?p ?qv.
?qv gr:hasValueFloat ?v.
?qv gr:hasUnitOfMeasurement ?uom.

Note: Instead of hasValueFloat, hasMaxValueFloat or hasMaxValue should be used, but this requires inferencing which may not be available on all endpoints.

Example: Query the Virtuoso LOD instance for the EAN code: Click here

Python Code

#!/usr/bin/env python
# encoding: utf-8
Created by Martin Hepp on 2009-06-15.
Copyright (c) 2009 Universität der Bundeswehr. All rights reserved.

import webbrowser
import urllib
def fetchProperties(ean):
'''Fetch product properties from the Semantic Web'''
query = """
PREFIX xsd: <>
PREFIX gr: <>
SELECT ?p ?v ?uom WHERE
?uri rdf:type gr:ProductOrServiceModel.
?uri gr:hasEAN_UCC-13 \""""
?uri ?p ?qv.
?qv gr:hasValueFloat ?v.
?qv gr:hasUnitOfMeasurement ?uom.

params = urllib.urlencode({'default-graph-uri': '', 'query': query,
'format': 'text/html', 'debug' : 'on', 'timeout' : ''})"" % params)
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
print 'Program completed.'

Sample Barcodes as PDF

Click on the following link to download a PDF document with barcodes that should work:

BarcodeFeatureDemo.pdf (file size: 103 KB, MIME type: application/pdf)