Programming the Semantic Web

Errata for Programming the Semantic Web

Submit your own errata for this product.


The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.


Color Key: Serious Technical Mistake Minor Technical Mistake Language or formatting error Typo Question Note Update



Version Location Description Submitted By Date Submitted
Safari Books Online 1.2.5
last paragraph

"In fact, many "customizable" data applications such as Saleforce.com" should read "In fact, many "customizable" data applications such as Salesforce.com".

Anonymous  Oct 17, 2009 
PDF Page 15
second sentence

"preforming" should be "performing"

Youdaman  Sep 15, 2010 
Printed Page 19
2nd paragraph

For those new to semantic web terminology, along with defining a "triple" in its sub-pred-obj form, you might want to add a sentence that a triple is, "An RDF graph, or simply a graph, is a set of RDF triples." (from http://www.w3.org/TR/rdf-mt/#graphdefs) This might help alleviate the confusion some users may have between Excel-type visual graphs and RDF graphs. It's a problem inadvertently compounded with examples such as on p. 22 and p. 27, where the image caption describes an RDF graph but could be easily mistaken meaning only the visual graph.

jworeilly  Nov 22, 2009 
Printed Page 23
3rd paragraph

You might want to note that the samples in the book work with Python v. 2.x, not version 3.x.

jworeilly  Nov 22, 2009 
Printed Page 28
First code snippet

The for loop: "for sub, pred, obj in graph1:" results in the error: "TypeError: iteration over non-sequence" Correcting the for loop to: "for sub, pred, obj in graph1.triples((None, None, None)):" Fixes that problem, but the subsequent line: " mergegraph.triples((None, None, None)).add((sub, pred, obj))" creates another problem: "AttributeError: 'generator' object has no attribute 'add'" which can be resolved with: " mergegraph.add((sub, pred, obj))" I propose that the corrected code snippet would be: for sub, pred, obj in graph1.triples((None, None, None)): mergegraph.add((sub, pred, obj)) for sub, pred, obj in graph2.triples((None, None, None)): mergegraph.add((sub, pred, obj))

davidpark1  Aug 20, 2009 
Printed Page 28
First code listing

Two issues of clarity really. First, the third line says "... load data into the graphs ..." without saying what data you mean or how to load it. Second, I wish you had spelled out the point that when you go into a for loop you actually need to tab in from the "..." prompt or you get an error. These may sound picky points, but remember that your reader (me, in this case) is new to this and it is not unreasonable in chapter 2 to have the blindingly obvious spelled out). Ian. --

ianpiper  Mar 24, 2010 
Printed Page 29
top code sample

Perhaps I mistyped the code tutorial examples, but the sample movies.csv data file downloaded from the book website (http://semprog.com/psw/chapter2/) appears not to contain an intersection of movies directed by Steven Spielberg and starring Harrison Ford. Uploading a corrected sample data file will fix this.

jworeilly  Nov 22, 2009 
Printed Page 29
Page 29 top code sample

I indeed made a mistake -- the intersection works as printed.

jworeilly  Nov 22, 2009 
Printed Page 30
1st code sample

A wrong method name is used on the SimpleGraph object. Typed into the Python console, the error shows up as: >>> from simplegraph import SimpleGraph >>> placegraph = SimpleGraph() >>> placegraph.loadfile("place_triples.txt") Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: SimpleGraph instance has no attribute 'loadfile' Changing the method name to "load" works though, as originally defined on page 24: >>> placegraph.load("place_triples.txt") On page 32 the correct method is used again.

Ben  Sep 05, 2009 
Printed Page 30
the first code snippet

On page 30 (Chapter 2) the first code snippet: >>> placegraph.loadfile("place_triples.txt") should be >>> placegraph.load("place_triples.txt")

Anonymous  Jan 15, 2010 
Printed Page 30
1st paragraph, 5th line

The line " >>> placegraph.loadfile("places_triples.txt")" generates an error. This is due to the fact there is no procedure in the class called "loadfile". Should be " >>> placegraph.load("places_triples.txt")"

Jeffery E. Bell  Jun 24, 2012 
Printed Page 33
middle of code sample at top of page

Needs another ">" before movie_stars=set()

jworeilly  Nov 22, 2009 
Printed Page 38
Figure 3-1

In the bottom circle in Figure 3-1, "Richard M. Daly" should be "Richard M. Daley"

Anonymous  Jul 10, 2010 
Printed Page 41
Last code snippet

The method SimpleGraph.query won't generate the output from the examples on page 42. Querying for the contributions results in this output: [{'?dollars': u'30700.0', '?cont': u'contrib285', '?company': u'BSC'}] The variable names are still prefixed with "?". This becomes a problem later on page 45 in the first code snippet, because the method InferenceRule.maketriples will try to unpack the binding's dictionary: def maketriples(self, binding): return self._maketriples(**binding) which will result in this error message: TypeError: _maketriples() got an unexpected keyword argument '?company' The fix is to change this line in SimpleGraph.query (shown on page 41) bpos[x] = pos to bpos[x[1:]] = pos This copies the variable name without the prefixed "?". Note: This error is already fixed in the Python files available for download.

Ben  Sep 09, 2009 
Printed Page 42
Python code session at bottom of page

from simplegraph import SimpleGraph() should be from simplegraph import SimpleGraph

Anonymous  Aug 24, 2009 
Printed Page 42
middle

Neither the code in the book on pp. 41-42 for "query" nor the code on the web site correctly handles the case where a query triple contains two identical variables each preceded by a question mark, such as "('?city','inside','?city')".

Anonymous  Dec 18, 2009 
PDF Page 44
class WestCoastRule(InferenceRule):

the code in this Python class is: > laxquery = [('?company', 'headquarters', 'Los_Angelese_California')] but it should be: > laxquery = [('?company', 'headquarters', 'Los_Angeles_California')]

Anonymous  Nov 03, 2012 
Printed Page 45
2nd code snippet

The method EnemyRule._maketriples does not return a list of tuples, as expected by applyinference. This is how it should look like: def _maketriples(self, person, enemy, rel, partner): return [(partner, 'enemy', enemy)]

Ben  Sep 09, 2009 
Printed Page 45
5th paragraph

In chapter 3 of the book, on page 45, I typed the following codes and got the following error messages: /* BEGIN */ C:\ProgSemanticWeb\SemanticWeb>c:\Python25\python.exe Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from simplegraphq import * Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named simplegraphq >>> from simplegraph import * >>> cg = SimpleGraph() >>> cg.load('celeb_triples.csv') >>> er = EnemyRule() Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'EnemyRule' is not defined >>> from inferencerule import * >>> er = EnemyRule() >>> list(cg.triples((None, 'enemy', None))) [(u'Jennifer Aniston', 'enemy', u'Angelina Jolie'), (u'Angelina Jolie', 'enemy', u'Jennifer Aniston'), (u'Sean Combs', 'enemy', u'Tupac Shakur'), (u'Jay- Z', 'enemy', u"Cam'ron"), (u'Shar Jackson', 'enemy', u'Britney Spears'), (u'Sean Combs', 'enemy', u'Suge Knight'), (u'Jay-Z', 'enemy', u'Nas'), (u'Lauren Conrad', 'enemy', u'Spencer Pratt'), (u'Britney Spears', 'enemy', u'Shar Jackson'), (u'Lauren Conrad', 'enemy', u'Heidi Montag')] >>> cg.applyinference(er) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "simplegraph.py", line 169, in applyinference new_triples = rule.maketriples(b) File "inferencerule.py", line 8, in maketriples return self._maketriples(**binding) TypeError: _maketriples() got an unexpected keyword argument '?rel' >>> /* END */ What is this type error? And, how can it be solved? Many thanks

Laurence Samuels  Sep 18, 2009 
PDF Page 45
>>> from simplegraphq import *

>>> from simplegraphq import * should be: >>> from simplegraph import *

Anonymous  Nov 03, 2012 
Printed Page 46
code snippet bottom of the page

There are some problems with the printed code. When following the book without downloading any of the code the following should be corrected: def getquery(self): return [('?place', 'address', '?address')] should be def getqueries(self): return [[('?place', 'address', '?address')]] Without these changes the geocoder will not match any queries and _maketriples will never be called.

Joris Slob  Jan 16, 2010 
PDF Page 46
code piece in section "Adding a geocoding rule"

In the code part: class GeocodeRule(InferenceRule): def getquery(self): return [('?place', 'address', '?address')] the return clause should be return [[('?place', 'address', '?address')]], or no result returned from the original query clause

Ning  Jun 01, 2015 
PDF Page 47
Interactive Interpreter code sample

The two lines which both read: list(geograph.triples((None, None, None)) are missing a final closing parenthesis and so should be changed to: list(geograph.triples((None, None, None)))

Bryce Thomas  Jan 27, 2010 
Printed Page 48
3rd code block

in the TouristyRule class the function getqueries doesn't return anything. This causes a "None not iterable" error. The final line in this method should be: return [tr]

Joris Slob  Feb 07, 2010 
Printed Page 77
first word on page

First word on page 77, "CUIREs", should be "CURIEs"

Anonymous  Jul 11, 2010 
PDF Page 79
Second last paragraph

A part of the paragraph reads "RDFa was specified as annotations on XHML[sic]". I imagine this was meant to read "RDFa was specified as annotations on XHTML" (XHTML instead of XHML).

Bryce Thomas  Jan 28, 2010 
Printed Page 80
last line

it's not that easy to install rdflib. On CentOS 5.4 & Windows 7 with Visual Studio, rdflib installation result in compilation error of sparkle related source.. I have found discuttion about pure python implementation here. http://groups.google.com/group/rdflib-dev/browse_thread/thread/612331d35399662c# And it worked fine. On the line 5 of the next page, from rdflib.Graph import ConjunctiveGraph must be from rdflib.graph import ConjunctiveGraph with the installation above.

tamagawa ryuji  Jan 01, 2010 
Printed Page 81
4th code listing

Command as written is: "list(g.triples((None, rdflib.URIRef('foaf:knows'), None)))" and it returns an empty list. I think this is because there's no xmlns identifying foaf:knows with http://xmlns.com/foaf/0.1/knows. Changing the command to "list(g.triples((None, rdflib.URIRef('http://xmlns.com/foaf/0.1/knows'), None)))" returns a list with 2 triples, the intended result, I think.

Peter Haglich  Sep 04, 2009 
Printed Page 81
2nd code sample

Code in the book is: me = URIRef("http://my.uri.com/goes/here") This should be: me = rdflib.URIRef("http://my.uri.com/goes/here")

jworeilly  Dec 17, 2009 
Printed Page 82
3rd code listing

Command is written RDF=rdflib.Namespace('http://www.w3.org/TR/rdf-schema/#') but this points to the rdfs namespace, which has no predicate "type". The command should have been: RDF = rdflib.Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#")

Peter Haglich  Sep 04, 2009 
Printed Page 82
Third code listing

'rdf-type-predicate' is not a valid python variable name - easily fixed by using underscores.

Duncan Parkes  Nov 17, 2012 
PDF Page 84
code example

The code example on page 84 shows a graph of movie data represented using the N3 format. The first line of code specifies a prefix "fb", however this prefix is not used in the rest of the code example. On page 73 there is another example of N3 code where prefixes are used for compaction. I believe the example on page 84 should use the prefix for compaction also but this has been overlooked.

Stewart Heckenberg  Nov 09, 2010 
PDF Page 84
code example

The code example on page 84 shows a graph of movie data represented using the N3 format. The first line of code specifies a prefix "fb", however this prefix is not used in the rest of the code example. On page 73 there is another example of N3 code where prefixes are used for compaction. I believe the example on page 84 should use the prefix for compaction also but this has been overlooked.

Stewart Heckenberg  Nov 09, 2010 
PDF Page 84
code example

i could be wrong about the prefix issue i submitted previously -- perhaps i'm confusing prefix with base (which is described in later paragraphs)?

Stewart Heckenberg  Nov 09, 2010 
PDF Page 88
last paragraph

"comparisons operators" -- should it be "comparison operators"?

Stewart Heckenberg  Nov 09, 2010 
Printed Page 91
Final code listing

The second prefix (rdf) in this query is unnecessary.

Duncan Parkes  Nov 17, 2012 
Printed Page 99
Code listing for function make_foaf_graph in the "for uri in current": loop

The code creates an instance of urllib2.Request but there is no corresponding import statement at the beginning of the code file.

Peter Haglich  Sep 10, 2009 
Safari Books Online 111
5th paragraph

The code for LOD as mentioned in the book is http://semprog.com/psw/chapter5/lod However, I couldn't download it from the link.

Anonymous  Nov 22, 2009 
Printed Page 111
1st paragraph, 1st sentence

"British Broadcasting Company (BBC)" should be changed to "British Broadcasting Corporation (BBC)". The BBC is not a commercial organization!

Andrew Bate  Mar 31, 2012 
Safari Books Online 114
2nd last line of function getBands4Location()

2nd last line of function getBands4Location() printed as g.parse(StringIO(dbpedia_data),format='xml') In fact, the data stored in dbpedia_data is in n3 format and the program looks good after changed to g.parse(StringIO(dbpedia_data),format='n3')

Damon Tsang  Nov 22, 2009 
Printed Page 122
First MQL example in curly braces

There is a missing double-quote after "/en/harrison/ford in the first example. It should read: {"id":"/en/harrison/ford", "/people/person/date_of_birth":null}

Mark Harrison  Feb 20, 2012 
Printed Page 133
2nd sentence

The statement "As mentioned earlier, the range is the source type for a property, and the domain is the destination type for a property" is incorrect and inconsistent with Figure 6.1. The statement should read: "As mentioned earlier, the domain is the source type for a property, and the range is the destination type for a property" See http://www.w3.org/TR/rdf-schema/#ch_range

Mark Harrison  Feb 20, 2012 
Printed Page 137-138
last paragraphs

Error in code snippet, might be a huge copy/pasting error because from ["#define all our triples =[from rdflib import ConjunctiveGraph " to the next page ]#define all our triples: it's the repetion of the beginning of the code snippet with the previous import and the definition of namespace Hope this help!

Anonymous  Dec 03, 2012 
Printed Page 147
Figures 6-11 and 6-12

The direction of all the arrows for property rdfs:subClassOf are all the wrong way round in both figures 6-11 and 6-12 and are inconsistent with Figure 6-3 on p133, which correctly shows that Film is a subClassOf Object

Mark Harrison  Feb 20, 2012 
Printed Page 158
hResume code example at start of page 158

The values of the title attributes are inconsistent with the human-readable values that the <abbr> elements enclose. The three lines of <abbr> elements should read: <abbr class="dtstart" title="2008-01-01">January 2008</abbr> <abbr class="dtend" title="2009-12-01">December 2009</abbr> <abbr class="duration" title="P1Y11M">(1 year 11 months)</abbr>

Mark Harrison  Feb 20, 2012 
Printed Page 202
Code example

By default the results from Sesame are in binary instead of the expected JSON. The GET message should contain the header "Accept: application/sparql-results+json". See http://www.openrdf.org/doc/sesame2/system/ch08.html#table-var-binding-formats Revised pysesame.py code example: from urllib import urlopen,quote_plus,URLopener ... def __getsparql__(self,method): request = URLopener() request.addheader("Accept", "application/sparql-results+json") data = request.open(self.baseurl+method).read() try: result=loads(data)['results']['bindings'] return result except: return [{'error':data}];

Simon Clarke  Mar 28, 2010 
PDF Page 209
1st paragraph

"http://semprog.com/psw/chapter8/celeb_fancy_exhibit.html" should be "http://semprog.com/psw/chapter8/celebs_fancy_exhibit.html"

zzljlu  Aug 12, 2010 
PDF Page 231
Second paragraph under heading "Loading the Data into Sesame

I believe the sentence that starts with "Sesame lets you use PUT through its....." should read "Sesame lets you use POST through its...." as it is a POST not a PUT request that gets used.

Bryce Thomas  Feb 08, 2010 
Printed Page 231
Middle, code example

There are two problems in postdata causing the convert_jobs.py to fail quietly. Firstly, there is an extra "/" before "repositories" in the path. Secondly, the POST message should contain the header "Content-Type: application/rdf+xml". See http://www.openrdf.org/doc/sesame2/system/ch08.html, section 8.5.1.5 import urllib2 ... def postdata(self,data): host=self.baseurl+'repositories/'+self.repository+'/statements' request = urllib2.Request(host,data) request.add_header("Content-Type", "application/rdf+xml") res=urllib2.urlopen(request) return res.read()

Simon Clarke  Mar 28, 2010 
Printed Page 242
sample code

The sample code on the page should demonstrate how to get stock data from Yahoo. It mistakenly shows duplicate code from the earlier Crunchbase example. The correct code is available at http://semprog.com/psw/chapter10/yahoo_finance_update.py

Geoff Blosser  Dec 20, 2009 
ePub Page 997
Geocoding

You suggest to use geocoder.us but that URL is down. I found an alternative one at this IP address 206.220.230.164. Using that IP instead of the URL in the book, you should be able to follow the instructions in the book with no problems.

Carlos Alejandro Jimenez Holmquist  Apr 28, 2018