Learning Sparql

37 views
Skip to first unread message

Bruce Whealton

unread,
Jan 25, 2012, 8:57:00 PM1/25/12
to TopBraid Suite Users
I am wondering why I cannot run the files from the book by Bob
DuCharme inside of TBC. I created a project called LearningSparql. I
then dragged the exercise files from where I had unzipped them and and
dropped them inside TBC inside the LearningSparql folder.

What step could I be missing? I then open up ex002.ttl inside TBC and
I don't see anything. I mean starting with owl:Thing there is nothing
in there. Needless to say the first query does not work.
I can do this from the command line. Although, it doesn't seem to
accept my path.
I have to type in c:\arq\bat\arq
to get arq to run. I have tried to put into the path c:\arq\bat and
also c:\arq
I know this is a bit off topic, though. I do have the ARQROOT set to
c:\arq

Anyway, I was curious as to why I cannot open ex002.ttl inside TBC.
The contents of the file are:

# filename: ex002.ttl

@prefix ab: <http://learningsparql.com/ns/addressbook#> .

ab:richard ab:homeTel "(229) 276-5135" .
ab:richard ab:email "rich...@hotmail.com" .

ab:cindy ab:homeTel "(245) 646-5488" .
ab:cindy ab:email "cin...@gmail.com" .

ab:craig ab:homeTel "(194) 966-1505" .
ab:craig ab:email "craig...@yahoo.com" .
ab:craig ab:email "c.e...@usairwaysgroup.com" .

Thanks,
Bruce

Bob DuCharme

unread,
Jan 25, 2012, 10:05:07 PM1/25/12
to topbrai...@googlegroups.com
Bruce,

As the book's second example, ex002.ttl is extremely simple. Three resources have two or three properties each, and rdf:type is not declared for any of them, which is why they don't show up under owl:Thing in TBC. The resources aren't declared to be of any type, and they have to be declared to be of type owl:Thing or some subclass of that to show up on that tree.

If you open ex002.ttl in TBC and then paste the ex003.rq query into the SPARQL view, the query does run as described in the book, except that you have to remove the blank lines from the query first because the TBC SPARQL view's syntax checker doesn't like blank lines. I just ran it with no problem. 

For arq issues, it would be better to ask on the jena mailing list (http://jena.sourceforge.net/support.html) or email me offline instead of putting the questions on the TopBraid mailing list. 

Bob




--
You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include TopBraid Composer,
TopBraid Live, TopBraid Ensemble, SPARQLMotion and SPIN.
To post to this group, send email to
topbrai...@googlegroups.com
To unsubscribe from this group, send email to
topbraid-user...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/topbraid-users?hl=en

Alexander Garcia Castro

unread,
Jan 25, 2012, 10:06:57 PM1/25/12
to topbrai...@googlegroups.com
is this book linked to TBC? if I dont want to use TBC will the book still be useful?
--
Alexander Garcia
Florida State University Guest Professor 
http://www.alexandergarcia.name/
http://www.usefilm.com/photographer/75943.html
http://www.linkedin.com/in/alexgarciac


Bob DuCharme

unread,
Jan 25, 2012, 10:49:57 PM1/25/12
to topbrai...@googlegroups.com
The book references TopBraid in the chapter on application development, and the upcoming expanded edition will describe other scenarios where TopBraid can help with application development. All of the book's examples will run in TopBraid (when blank lines are removed from the SPARQL queries), but as an O'Reilly book on a W3C standard, it provides more detail on using open source software--in this case, ARQ and Fuseki--for running the examples.

Bob

Scott Henninger

unread,
Jan 26, 2012, 1:29:46 AM1/26/12
to TopBraid Suite Users
Bruce; I think you will find that the triples are there, but the data
you show just doesn't have any modeling elements - class and property
definitions. This is perfectly legitimate for RDF data. You can
always find out what data is in a model with the Triples view. Go to
Window > Show View > Triples. A view will appear and you can select
the namespace you want to view.

Given that you are looking into SPARQL, to find all triples you can
always run a SPO query:

SELECT *
WHERE
{ ?s ?p ?o
}

The SPARQL View will limit you to the first 1000 matches (which can be
modified in Preferences), so it is safe to run across large data
sets. If you run this with "Run on base model only" (mode icon in
upper-right of SPARQL view) you will get only the triples defined in
the currently open model.

-- Scott

On Jan 25, 7:57 pm, Bruce Whealton <brucewheal...@gmail.com> wrote:
> I am wondering why I cannot run the files from the book by Bob
> DuCharme inside of TBC.  I created a project called LearningSparql.  I
> then dragged the exercise files from where I had unzipped them and and
> dropped them inside TBC inside the LearningSparql folder.
>
> What step could I be missing?  I then open up ex002.ttl inside TBC and
> I don't see anything.  I mean starting with owl:Thing there is nothing
> in there.  Needless to say the first query does not work.
> I can do this from the command line.  Although, it doesn't seem to
> accept my path.
> I have to type in c:\arq\bat\arq
> to get arq to run.  I have tried to put into the path c:\arq\bat and
> also c:\arq
> I know this is a bit off topic, though.  I do have the ARQROOT set to
> c:\arq
>
> Anyway, I was curious as to why I cannot open ex002.ttl inside TBC.
> The contents of the file are:
>
> # filename: ex002.ttl
>
> @prefix ab: <http://learningsparql.com/ns/addressbook#> .
>
> ab:richard ab:homeTel "(229) 276-5135" .
> ab:richard ab:email   "richar...@hotmail.com" .
>
> ab:cindy ab:homeTel "(245) 646-5488" .
> ab:cindy ab:email   "cin...@gmail.com" .
>
> ab:craig ab:homeTel "(194) 966-1505" .
> ab:craig ab:email   "craigel...@yahoo.com" .
> ab:craig ab:email   "c.el...@usairwaysgroup.com" .
>
> Thanks,
> Bruce

Bruce Whealton

unread,
Jan 28, 2012, 4:16:54 AM1/28/12
to TopBraid Suite Users
Bob, I was confused. You said the SPARQL worked if you edited it.
However, you had said there was a problem with the
ex002.ttl. I'm almost embrassed to be asking something so simple but
getting a good feel for working with any type of data
is important to me. Indeed, that is one of the features of TBC and in
the book you point out that Sparql can be used to query various
types of data, spreadsheets, relational DB. So, I would first need to
define a vocabulary that would describe the address book
and/or relate it to existing vocabularies, like for this FOAF might be
fine.
Thanks,
Bruce

On Jan 25, 10:05 pm, Bob DuCharme <bducha...@topquadrant.com> wrote:
> Bruce,
>
> As the book's second example, ex002.ttl is extremely simple. Three
> resources have two or three properties each, and rdf:type is not declared
> for any of them, which is why they don't show up under owl:Thing in TBC.
> The resources aren't declared to be of any type, and they have to be
> declared to be of type owl:Thing or some subclass of that to show up on
> that tree.
>
> If you open ex002.ttl in TBC and then paste the ex003.rq query into the
> SPARQL view, the query does run as described in the book, except that you
> have to remove the blank lines from the query first because the TBC SPARQL
> view's syntax checker doesn't like blank lines. I just ran it with no
> problem.
>
> For arq issues, it would be better to ask on the jena mailing list (http://jena.sourceforge.net/support.html) or email me offline instead of
> putting the questions on the TopBraid mailing list.
>
> Bob
>
> On Wed, Jan 25, 2012 at 8:57 PM, Bruce Whealton <brucewheal...@gmail.com>wrote:
>
>
>
>
>
>
>
> > I am wondering why I cannot run the files from the book by Bob
> > DuCharme inside of TBC.  I created a project called LearningSparql.  I
> > then dragged the exercise files from where I had unzipped them and and
> > dropped them inside TBC inside the LearningSparql folder.
>
> > What step could I be missing?  I then open up ex002.ttl inside TBC and
> > I don't see anything.  I mean starting with owl:Thing there is nothing
> > in there.  Needless to say the first query does not work.
> > I can do this from the command line.  Although, it doesn't seem to
> > accept my path.
> > I have to type in c:\arq\bat\arq
> > to get arq to run.  I have tried to put into the path c:\arq\bat and
> > also c:\arq
> > I know this is a bit off topic, though.  I do have the ARQROOT set to
> > c:\arq
>
> > Anyway, I was curious as to why I cannot open ex002.ttl inside TBC.
> > The contents of the file are:
>
> > # filename: ex002.ttl
>
> > @prefix ab: <http://learningsparql.com/ns/addressbook#> .
>
> > ab:richard ab:homeTel "(229) 276-5135" .
> > ab:richard ab:email   "richar...@hotmail.com" .
>
> > ab:cindy ab:homeTel "(245) 646-5488" .
> > ab:cindy ab:email   "cin...@gmail.com" .
>
> > ab:craig ab:homeTel "(194) 966-1505" .
> > ab:craig ab:email   "craigel...@yahoo.com" .
> > ab:craig ab:email   "c.el...@usairwaysgroup.com" .

Bob DuCharme

unread,
Jan 28, 2012, 9:57:41 AM1/28/12
to topbrai...@googlegroups.com
I didn't say that there was a problem with ex002.ttl, only that it was extremely simple. The book is an introduction to the SPARQL query language, not to semantic web data modeling, for which Dean Allemang and Jim Hendler already wrote the excellent "Semantic Web for the Working Ontologist." The expanded edition of "Learning SPARQL" will include a section on querying for inferenced triples, especially those entailed by RDFS properties such as rdfs:type, rdfs:domain, and rdfs:range. 

The main example in my book's section on converting data with CONSTRUCT queries, which begins on page 114, is about how to convert the book's sample address book data from the demo vocabulary it uses to FOAF. When you get to that page, try this in TBC:

1. open the book's ex012.ttl data file and drag foaf.ttl from the Common folder of the TopBraid project into the Imports view. This defines the vocabulary that the result of the conversion will use. 

2. Paste the ex194.rq query into the SPARQL view, remove the two blank lines, and  add the triple 

   ?s a foaf:Person .

inside the curly braces after the CONSTRUCT keyword 

3. Run the query, select all the resulting triples on the right, and pick "Assert selected constructed triples" from that view's menu.

In the classes view, under owl:Thing/foaf:Agent, you will see that foaf:Person now has 3 instances that you can see in the Instances view. 

It's very common, when relating data from different sources that use different vocabularies, to use CONSTRUCT queries to align the data like this. 

Bob

Group "TopBraid Suite Users", the topics of which include Enterprise Vocabulary Network (EVN), TopBraid Composer,

Scott Henninger

unread,
Jan 31, 2012, 1:50:42 PM1/31/12
to TopBraid Suite Users
Alexander, there are a number of ways you can use and *learn* SPARQL
with TopBraid Suite. First, the syntax-directed editor in the SPARQL
view provides fast feedback to develop error-free queries. The auto-
complete feature is invaluable for creating queries that not only have
the correct syntax, but include correct references to RDF data. The
instant feedback you get from the SPARQL view is unparalleled for
SPARQL tools.

You can also use the visual graph representation (in TBC-ME) to turn a
graph structure into a query. There is an example in Help > How to? >
Creating SPARQL Queries by Example, and we can provide more
information and answer questions, as needed. This is really a good
way to start understanding the relationship between RDF and SPARQL.

TopBraid Ensemble also has a query-by-example facility that is also a
nice way to browse linked data. Start TBC-ME and point a browser to
http://localhost:8083/tbl. Choose Default Application and choose your
data graph (in the Composer workspace). When the application starts,
go to the Graph Editor and Query view. You can either drag/drop a
resource from the Results grid or use the Add Node button to add a
resource to the view's workspace. When you click on this resource,
panels appear on either side representing links referenced by the
resource (outgoing relationships) and links that reference the
resource (incoming relationships). It's a very nice visual way to
step through linked data.

If you then generalize a resource in the graph, it becomes a variable
in a SPARQL query. Note that this is the converse of the Composer
approach, which turns everything into a variable unless chosen. In
this case, everything is a SPARQL URI (constant) unless you
"generalize" into a variable. Choose Submit Query and the results
appear in the Results grid.

It's also easy to set up Web services that submits SPARQL queries to a
TBL service, including the TBC-ME server running on localhost. For
example, you can set up a simple HTML page that gets a query and
submits to the query, receiving results in standard SPARQL endpoint
formats. That doesn't have the advantages of developing queries with
Composer's SPARQL View, but will work if that is desired as a UI. An
example with SPARQL Endpoints is given in our blog at
http://topquadrantblog.blogspot.com/2010/05/how-to-publish-your-linked-data-with.html.

-- Scott

On Jan 25, 9:06 pm, Alexander Garcia Castro <alexgarc...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages