Re: @base and @prefix in riot's Turtle output

2016-09-08 Thread Andy Seaborne

Hi Frans,

There isn't a way for BASE.  Models don't carry BASE around with them 
like they do for a prefix mapping so while the writer do provide base 
support, the data doesn't flow-end-to-end.


There are problems with BASE anyway - it's really for when there are 
relative URIs and teh base comes from outside (i.e the place the data is 
read from.)


The usual approach is to define prefix ":" to be the URI for the data 
for the file.


Andy

On 08/09/16 12:59, Frans Knibbe wrote:

Hi Andy,

Thanks for the help. I have made a file with only prefixes and a command
like the one below works nice:

riot -formatted=ttl prefixes.ttl in.nt > out.ttl

It is a big improvement. Is there perhaps a way to use @base too? If I put
@base in the prefixes.ttl file it seems to be ignored, just like a
specification of the base URI as a command line parameter.

Greetings,
Frans


On 6 September 2016 at 12:01, Andy Seaborne  wrote:


Hi Frans,

See "riot --help" for your version.
https://jena.apache.org/documentation/io/#command-line-tools

Currently:

--output=FMT
   Output in the given format, streaming if possible.
--formatted=FMT
Output, using pretty printing (consumes memory)
--stream=FMT
   Output, using a streaming format

and make FMT "TTL"

Note that --formatted (the prettiest) has to read all input into memory
before printing begins which can be an issue at large scale, the other
forms don't need this.

To set particular prefixes when the data does provide them, add your own
Turtle file with just prefixes in it.

riot --formatted=TTL myprefixes.ttl data...data 2>/dev/null

Andy


On 06/09/16 10:38, Frans Knibbe wrote:


Hello,

I use riot to convert RDF files to different formats on the command line.
It works well, but I wonder if there is an option to have @base and
@prefix
definitions in the output in turtle format. In many cases that would
result
in more compact files that are easier to read for humans.

I can image riot could identify repeating URI prefixes itself, or perhaps
a
file with  @prefix definitions could be supplied as a parameter...

As for @base, I see that there is a parameter --base=URI for riot. But
using it does not seem to give an @base in turtle output.

Greetings,
Frans






Re: Comparing ResultSet objects, problem with CSV

2016-09-08 Thread Andy Seaborne



On 08/09/16 16:24, Andy Seaborne wrote:

The TSV format is the lossless form of you want that style of output.

  if

(sorry - especially bad typing day today)




I am testing a very simple case with a ResultSet of just 4 rows.
Using Jena 2.11.0

Any thoughts?


Upgrade? 2.11 is quite old.

Andy

On 08/09/16 14:42, Rob Vesse wrote:

The CSV format is explicitly defined to be a lossy format so some
information can and will be lost when serialising to CSV. Specifically
the datatypes and language tags for literals and literals/URIs may not
be distinguishable due to their encoding.

From the spec
(http://www.w3.org/TR/2013/REC-sparql11-results-csv-tsv-20130321/#intro):

The SPARQL Results CSV Results Format is a lossy encoding of a table
of results. It does not encode all the details of each RDF term in the
results but instead just gives a string without indicating the type of
the term (IRI, Literal, Literal with datatype, Literal with language,
or blank node). This makes it simple to consume data, such as text and
numbers, in applications without needing to understand the details of
RDF. In some applications, guesses as to which elements are hyperlinks
are made pragmatically, for example, guessing that strings starting
"http://"; are links.

Rob

On 08/09/2016 14:04, "Nikolaos Beredimas"  wrote:

I have a method that does a SPARQL select query and returns
results in XML,
JSON and CSV using
outputAsCSV



(OutputStream



 outStream, ResultSet



 resultSet)
outputAsJSON



(OutputStream



 outStream, ResultSet



 resultSet)
outputAsXML



(OutputStream



 outStream, ResultSet



 qresults)

When trying to unit test it I have a problem with the CSV case.
I have tried
ResultSetCompare



.equalsByTerm



(ResultSet



 rs1, ResultSet



 rs2)
ResultSetCompare



.equalsByValue



(ResultSet



 rs1, ResultSet



 rs2)
ResultSetCompare



.isomorphic



(ResultSet



 rs1, ResultSet



 rs2)
and they all fail to return true.

Compared ResultSet objects are converted to ResultSetRewindable
before
comparing.
JSON and XML cases work as expected (return true), but CSV fails.

I am testing a very simple case with a ResultSet of just 4 rows.
Using Jena 2.11.0

Any thoughts?

Nikos.








Re: Comparing ResultSet objects, problem with CSV

2016-09-08 Thread Andy Seaborne

The TSV format is the lossless form of you want that style of output.

> I am testing a very simple case with a ResultSet of just 4 rows.
> Using Jena 2.11.0
>
> Any thoughts?

Upgrade? 2.11 is quite old.

Andy

On 08/09/16 14:42, Rob Vesse wrote:

The CSV format is explicitly defined to be a lossy format so some information 
can and will be lost when serialising to CSV. Specifically the datatypes and 
language tags for literals and literals/URIs may not be distinguishable due to 
their encoding.

From the spec 
(http://www.w3.org/TR/2013/REC-sparql11-results-csv-tsv-20130321/#intro):

The SPARQL Results CSV Results Format is a lossy encoding of a table of results. It does 
not encode all the details of each RDF term in the results but instead just gives a 
string without indicating the type of the term (IRI, Literal, Literal with datatype, 
Literal with language, or blank node). This makes it simple to consume data, such as text 
and numbers, in applications without needing to understand the details of RDF. In some 
applications, guesses as to which elements are hyperlinks are made pragmatically, for 
example, guessing that strings starting "http://"; are links.

Rob

On 08/09/2016 14:04, "Nikolaos Beredimas"  wrote:

I have a method that does a SPARQL select query and returns results in XML,
JSON and CSV using
outputAsCSV


(OutputStream


 outStream, ResultSet


 resultSet)
outputAsJSON


(OutputStream


 outStream, ResultSet


 resultSet)
outputAsXML


(OutputStream


 outStream, ResultSet


 qresults)

When trying to unit test it I have a problem with the CSV case.
I have tried
ResultSetCompare


.equalsByTerm


(ResultSet


 rs1, ResultSet


 rs2)
ResultSetCompare


.equalsByValue


(ResultSet


 rs1, ResultSet


 rs2)
ResultSetCompare


.isomorphic


(ResultSet


 rs1, ResultSet


 rs2)
and they all fail to return true.

Compared ResultSet objects are converted to ResultSetRewindable before
comparing.
JSON and XML cases work as expected (return true), but CSV fails.

I am testing a very simple case with a ResultSet of just 4 rows.
Using Jena 2.11.0

Any thoughts?

Nikos.








Re: Comparing ResultSet objects, problem with CSV

2016-09-08 Thread Nikolaos Beredimas
Thank you for that,

Nikos.

On Thu, Sep 8, 2016 at 4:42 PM, Rob Vesse  wrote:

> The CSV format is explicitly defined to be a lossy format so some
> information can and will be lost when serialising to CSV. Specifically the
> datatypes and language tags for literals and literals/URIs may not be
> distinguishable due to their encoding.
>
> From the spec (http://www.w3.org/TR/2013/REC-sparql11-results-csv-tsv-
> 20130321/#intro):
>
> The SPARQL Results CSV Results Format is a lossy encoding of a table of
> results. It does not encode all the details of each RDF term in the results
> but instead just gives a string without indicating the type of the term
> (IRI, Literal, Literal with datatype, Literal with language, or blank
> node). This makes it simple to consume data, such as text and numbers, in
> applications without needing to understand the details of RDF. In some
> applications, guesses as to which elements are hyperlinks are made
> pragmatically, for example, guessing that strings starting "http://"; are
> links.
>
> Rob
>
> On 08/09/2016 14:04, "Nikolaos Beredimas"  wrote:
>
> I have a method that does a SPARQL select query and returns results in
> XML,
> JSON and CSV using
> outputAsCSV
>  apache/jena/query/ResultSetFormatter.html#outputAsCSV-java.io.
> OutputStream-org.apache.jena.query.ResultSet->
> (OutputStream
>  OutputStream.html?is-external=true>
>  outStream, ResultSet
>  apache/jena/query/ResultSet.html>
>  resultSet)
> outputAsJSON
>  apache/jena/query/ResultSetFormatter.html#outputAsJSON-java.io.
> OutputStream-org.apache.jena.query.ResultSet->
> (OutputStream
>  OutputStream.html?is-external=true>
>  outStream, ResultSet
>  apache/jena/query/ResultSet.html>
>  resultSet)
> outputAsXML
>  apache/jena/query/ResultSetFormatter.html#outputAsXML-java.io.
> OutputStream-org.apache.jena.query.ResultSet->
> (OutputStream
>  OutputStream.html?is-external=true>
>  outStream, ResultSet
>  apache/jena/query/ResultSet.html>
>  qresults)
>
> When trying to unit test it I have a problem with the CSV case.
> I have tried
> ResultSetCompare
>  apache/jena/sparql/resultset/ResultSetCompare.html#ResultSetCompare-->
> .equalsByTerm
>  apache/jena/sparql/resultset/ResultSetCompare.html#
> equalsByTerm-org.apache.jena.query.ResultSet-org.apache.
> jena.query.ResultSet->
> (ResultSet
>  apache/jena/query/ResultSet.html>
>  rs1, ResultSet
>  apache/jena/query/ResultSet.html>
>  rs2)
> ResultSetCompare
>  apache/jena/sparql/resultset/ResultSetCompare.html#ResultSetCompare-->
> .equalsByValue
>  apache/jena/sparql/resultset/ResultSetCompare.html#
> equalsByValue-org.apache.jena.query.ResultSet-org.apache.
> jena.query.ResultSet->
> (ResultSet
>  apache/jena/query/ResultSet.html>
>  rs1, ResultSet
>  apache/jena/query/ResultSet.html>
>  rs2)
> ResultSetCompare
>  apache/jena/sparql/resultset/ResultSetCompare.html#ResultSetCompare-->
> .isomorphic
>  apache/jena/sparql/resultset/ResultSetCompare.html#
> isomorphic-org.apache.jena.query.ResultSet-org.apache.
> jena.query.ResultSet->
> (ResultSet
>  apache/jena/query/ResultSet.html>
>  rs1, ResultSet
>  apache/jena/query/ResultSet.html>
>  rs2)
> and they all fail to return true.
>
> Compared ResultSet objects are converted to ResultSetRewindable before
> comparing.
> JSON and XML cases work as expected (return true), but CSV fails.
>
> I am testing a very simple case with a ResultSet of just 4 rows.
> Using Jena 2.11.0
>
> Any thoughts?
>
> Nikos.
>
>
>
>
>
>
>


Re: Comparing ResultSet objects, problem with CSV

2016-09-08 Thread Rob Vesse
The CSV format is explicitly defined to be a lossy format so some information 
can and will be lost when serialising to CSV. Specifically the datatypes and 
language tags for literals and literals/URIs may not be distinguishable due to 
their encoding.

>From the spec 
>(http://www.w3.org/TR/2013/REC-sparql11-results-csv-tsv-20130321/#intro):

The SPARQL Results CSV Results Format is a lossy encoding of a table of 
results. It does not encode all the details of each RDF term in the results but 
instead just gives a string without indicating the type of the term (IRI, 
Literal, Literal with datatype, Literal with language, or blank node). This 
makes it simple to consume data, such as text and numbers, in applications 
without needing to understand the details of RDF. In some applications, guesses 
as to which elements are hyperlinks are made pragmatically, for example, 
guessing that strings starting "http://"; are links.

Rob

On 08/09/2016 14:04, "Nikolaos Beredimas"  wrote:

I have a method that does a SPARQL select query and returns results in XML,
JSON and CSV using
outputAsCSV


(OutputStream


 outStream, ResultSet


 resultSet)
outputAsJSON


(OutputStream


 outStream, ResultSet


 resultSet)
outputAsXML


(OutputStream


 outStream, ResultSet


 qresults)

When trying to unit test it I have a problem with the CSV case.
I have tried
ResultSetCompare


.equalsByTerm


(ResultSet


 rs1, ResultSet


 rs2)
ResultSetCompare


.equalsByValue


(ResultSet


 rs1, ResultSet


 rs2)
ResultSetCompare


.isomorphic


(ResultSet


 rs1, ResultSet


 rs2)
and they all fail to return true.

Compared ResultSet objects are converted to ResultSetRewindable before
comparing.
JSON and XML cases work as expected (return true), but CSV fails.

I am testing a very simple case with a ResultSet of just 4 rows.
Using Jena 2.11.0

Any thoughts?

Nikos.








Re: Writing Jena Model to CSV

2016-09-08 Thread lookman sanni
Thanks. That is what I did finally...laying the data down as wanted from a
ResultSet.

Rgds,

On Thu, Sep 8, 2016 at 9:27 AM, Nikolaos Beredimas 
wrote:

> CSV is not a valid RDF serialization format as mentioned (only as a format
> for SPARQL results).
>
> If you want something similar to CSV for serializing an RDF Model, try
> using N-triples.
>
> On Thu, Sep 8, 2016 at 10:22 AM, Martynas Jusevičius <
> marty...@graphity.org>
> wrote:
>
> > I think CSV is for writing ResultSet (SELECT results), not Model
> > (CONSTRUCT/DESCRIBE results).
> >
> > On Wed, 7 Sep 2016 at 23:37, lookman sanni  wrote:
> >
> > > Hi all,
> > >
> > > I am trying in vain to write a Jena model to a text file using
> > > RDFDataMgr.write(outputstream, dataset2, lang).
> > >
> > > This works well for Lang such as RDFXML, TRIG, TURTLE, NQUADS. However
> > for
> > > Lang.CSV, it is firing a RiotException of which I have no idea:
> > >
> > >
> > > *Exception in thread "main" org.apache.jena.riot.RiotException: No
> graph
> > > writer for null*
> > > * at
> > > org.apache.jena.riot.RDFDataMgr.createGraphWriter$(
> > RDFDataMgr.java:1199)*
> > > * at org.apache.jena.riot.RDFDataMgr.write$(RDFDataMgr.java:1211)*
> > > * at org.apache.jena.riot.RDFDataMgr.write(RDFDataMgr.java:1004)*
> > > * at org.apache.jena.riot.RDFDataMgr.write(RDFDataMgr.java:995)*
> > > * at org.apache.jena.riot.RDFDataMgr.write(RDFDataMgr.java:936)*
> > > * at *
> > >
> > > Has anyone come across this in the past and has some hints on its
> why/how
> > > to solve it ?
> > >
> > > Thanks, Lookman
> > >
> > > --
> > > Best Regards
> > >
> > > Lookman SANNI
> > >
> >
>



-- 
Best Regards

Lookman SANNI


Comparing ResultSet objects, problem with CSV

2016-09-08 Thread Nikolaos Beredimas
I have a method that does a SPARQL select query and returns results in XML,
JSON and CSV using
outputAsCSV

(OutputStream

 outStream, ResultSet

 resultSet)
outputAsJSON

(OutputStream

 outStream, ResultSet

 resultSet)
outputAsXML

(OutputStream

 outStream, ResultSet

 qresults)

When trying to unit test it I have a problem with the CSV case.
I have tried
ResultSetCompare

.equalsByTerm

(ResultSet

 rs1, ResultSet

 rs2)
ResultSetCompare

.equalsByValue

(ResultSet

 rs1, ResultSet

 rs2)
ResultSetCompare

.isomorphic

(ResultSet

 rs1, ResultSet

 rs2)
and they all fail to return true.

Compared ResultSet objects are converted to ResultSetRewindable before
comparing.
JSON and XML cases work as expected (return true), but CSV fails.

I am testing a very simple case with a ResultSet of just 4 rows.
Using Jena 2.11.0

Any thoughts?

Nikos.


Re: Relationship between similar columns from multiple databases

2016-09-08 Thread रविशंकर नायर
Sure will do, thanks a lot for pointers and help.

Best, Ravion

On Thu, Sep 8, 2016 at 8:08 AM, A. Soroka  wrote:

> I think you will want to start discussion of your question with the people
> who actually support that product. It's not a part of Jena.
>
> ---
> A. Soroka
> The University of Virginia Library
>
> > On Sep 7, 2016, at 6:28 PM, ☼ R Nair (रविशंकर नायर) <
> ravishankar.n...@gmail.com> wrote:
> >
> > All,
> >
> > Just saw this from a google search : www.d2rq.org. Quoting below the
> > headings from site:
> >
> > The D2RQ Platform is a system for accessing relational databases as
> > virtual, read-only RDF graphs. It offers RDF-based access to the content
> of
> > relational databases without having to replicate it into an RDF store.
> > Using D2RQ you can:
> >
> >   - query a non-RDF database using SPARQL
> >   
> >   - access the content of the database as Linked Data
> >    over the Web
> >   - create custom dumps of the database in RDF formats for loading into
> an
> >   RDF store
> >   - access information in a non-RDF database using the Apache Jena API
> >   
> >
> > D2RQ is Open Source software and published under the Apache license
> > . The source code is
> available
> > on GitHub . You can contact the dev team
> > through the issue tracker .
> >
> > Kindly advise whether this would suffice my need for finding the
> > relationships for autojoin between multiple tables in single RDBMS or
> > multiple instances of RDBMS.
> >
> >
> > Best regards,
> >
> > Ravion
> >
> >
> >
> >
> > On Wed, Sep 7, 2016 at 6:16 PM, ☼ R Nair (रविशंकर नायर) <
> > ravishankar.n...@gmail.com> wrote:
> >
> >> Do you have it inn GITHUB, can it be shared?
> >>
> >> Best,  Ravion
> >>
> >> On Sep 7, 2016 3:19 PM, "Paul Tyson"  wrote:
> >>
> >>> I wrote my own R2RML converter using Jena lib. It seemed cheapest and
> >>> easiest at the time (a few years ago). I have not surveyed current
> >>> offerings in this space.
> >>>
> >>> Best,
> >>> --Paul
> >>>
>  On Sep 7, 2016, at 14:13, Martynas Jusevičius 
> >>> wrote:
> 
>  Paul,
> 
>  What are you using for R2RML?
> 
>  Ontop looks promising: http://ontop.inf.unibz.it/
> 
> > On Wed, Sep 7, 2016 at 9:11 PM, Paul Tyson 
> >>> wrote:
> > Yes, I am using R2RML to convert 4 big PLM DBs into RDF, load in Jena
> >>> TDB and serve via fuseki for data mashups and inconsistency reports.
> Works
> >>> very well.
> >
> > Best,
> > --Paul
> >
> >> On Sep 7, 2016, at 13:39, Martynas Jusevičius <
> marty...@graphity.org>
> >>> wrote:
> >>
> >> I think R2RML and GRDDL could be of interest to you:
> >> https://www.w3.org/TR/r2rml/
> >> https://www.w3.org/TR/grddl/
> >>
> >> On Wed, Sep 7, 2016 at 8:00 PM, ☼ R Nair (रविशंकर नायर)
> >>  wrote:
> >>> Agree, the question is whether an RDF can be created out of the
> data
> >>> from
> >>> multiple data sources and use it for semantic correlation. That
> >>> would turn
> >>> the world round. In my organization,  there are at least a PB of
> >>> data lying
> >>> in disparate sources, untapped because , they are legacy and none
> >>> knows the
> >>> relationships until explored manually. If Jean is not, any
> >>> suggestions to
> >>> manage this? Thanks
> >>>
> >>> Best, Ravion
> >>>
> >>> On Sep 7, 2016 1:55 PM, "A. Soroka"  wrote:
> >>>
> >>> Jena is an RDF framework-- it's not really designed to integrate
> SQL
> >>> databases. Are you sure you are using the right product? Does your
> >>> use case
> >>> involve a good deal of RDF processing?
> >>>
> >>> ---
> >>> A. Soroka
> >>> The University of Virginia Library
> >>>
> > On Sep 7, 2016, at 1:43 PM, ☼ R Nair (रविशंकर नायर) <
>  ravishankar.n...@gmail.com> wrote:
> 
>  All,
> 
>  I am new to Jena. I would like to query two databases, mysql and
> >>> Oracle.
>  Assume that there are similar columns in both. For example MYSQL
> >>> contains
> >>> a
>  table EMP with ENAME column. Oracle contains, say, DEPT table with
>  EMPLOYEENAME column. What are the steps if I want Jena to find out
> >>> ENAME
> >>> of
>  MYSQL is same as EMPLOYEENAME column of Oracle, ( and so can be
> >>> joined).
> >>> Is
>  this possible, at least to get an output saying both columns are
> >>> similar?
>  If so, how, thanks and appreciate your help.
> 
>  Best, Ravion
> >
> >>>
> >>>
>
>


Re: Relationship between similar columns from multiple databases

2016-09-08 Thread A. Soroka
I think you will want to start discussion of your question with the people who 
actually support that product. It's not a part of Jena.

---
A. Soroka
The University of Virginia Library

> On Sep 7, 2016, at 6:28 PM, ☼ R Nair (रविशंकर नायर) 
>  wrote:
> 
> All,
> 
> Just saw this from a google search : www.d2rq.org. Quoting below the
> headings from site:
> 
> The D2RQ Platform is a system for accessing relational databases as
> virtual, read-only RDF graphs. It offers RDF-based access to the content of
> relational databases without having to replicate it into an RDF store.
> Using D2RQ you can:
> 
>   - query a non-RDF database using SPARQL
>   
>   - access the content of the database as Linked Data
>    over the Web
>   - create custom dumps of the database in RDF formats for loading into an
>   RDF store
>   - access information in a non-RDF database using the Apache Jena API
>   
> 
> D2RQ is Open Source software and published under the Apache license
> . The source code is 
> available
> on GitHub . You can contact the dev team
> through the issue tracker .
> 
> Kindly advise whether this would suffice my need for finding the
> relationships for autojoin between multiple tables in single RDBMS or
> multiple instances of RDBMS.
> 
> 
> Best regards,
> 
> Ravion
> 
> 
> 
> 
> On Wed, Sep 7, 2016 at 6:16 PM, ☼ R Nair (रविशंकर नायर) <
> ravishankar.n...@gmail.com> wrote:
> 
>> Do you have it inn GITHUB, can it be shared?
>> 
>> Best,  Ravion
>> 
>> On Sep 7, 2016 3:19 PM, "Paul Tyson"  wrote:
>> 
>>> I wrote my own R2RML converter using Jena lib. It seemed cheapest and
>>> easiest at the time (a few years ago). I have not surveyed current
>>> offerings in this space.
>>> 
>>> Best,
>>> --Paul
>>> 
 On Sep 7, 2016, at 14:13, Martynas Jusevičius 
>>> wrote:
 
 Paul,
 
 What are you using for R2RML?
 
 Ontop looks promising: http://ontop.inf.unibz.it/
 
> On Wed, Sep 7, 2016 at 9:11 PM, Paul Tyson 
>>> wrote:
> Yes, I am using R2RML to convert 4 big PLM DBs into RDF, load in Jena
>>> TDB and serve via fuseki for data mashups and inconsistency reports. Works
>>> very well.
> 
> Best,
> --Paul
> 
>> On Sep 7, 2016, at 13:39, Martynas Jusevičius 
>>> wrote:
>> 
>> I think R2RML and GRDDL could be of interest to you:
>> https://www.w3.org/TR/r2rml/
>> https://www.w3.org/TR/grddl/
>> 
>> On Wed, Sep 7, 2016 at 8:00 PM, ☼ R Nair (रविशंकर नायर)
>>  wrote:
>>> Agree, the question is whether an RDF can be created out of the data
>>> from
>>> multiple data sources and use it for semantic correlation. That
>>> would turn
>>> the world round. In my organization,  there are at least a PB of
>>> data lying
>>> in disparate sources, untapped because , they are legacy and none
>>> knows the
>>> relationships until explored manually. If Jean is not, any
>>> suggestions to
>>> manage this? Thanks
>>> 
>>> Best, Ravion
>>> 
>>> On Sep 7, 2016 1:55 PM, "A. Soroka"  wrote:
>>> 
>>> Jena is an RDF framework-- it's not really designed to integrate SQL
>>> databases. Are you sure you are using the right product? Does your
>>> use case
>>> involve a good deal of RDF processing?
>>> 
>>> ---
>>> A. Soroka
>>> The University of Virginia Library
>>> 
> On Sep 7, 2016, at 1:43 PM, ☼ R Nair (रविशंकर नायर) <
 ravishankar.n...@gmail.com> wrote:
 
 All,
 
 I am new to Jena. I would like to query two databases, mysql and
>>> Oracle.
 Assume that there are similar columns in both. For example MYSQL
>>> contains
>>> a
 table EMP with ENAME column. Oracle contains, say, DEPT table with
 EMPLOYEENAME column. What are the steps if I want Jena to find out
>>> ENAME
>>> of
 MYSQL is same as EMPLOYEENAME column of Oracle, ( and so can be
>>> joined).
>>> Is
 this possible, at least to get an output saying both columns are
>>> similar?
 If so, how, thanks and appreciate your help.
 
 Best, Ravion
> 
>>> 
>>> 



Re: @base and @prefix in riot's Turtle output

2016-09-08 Thread Frans Knibbe
Hi Andy,

Thanks for the help. I have made a file with only prefixes and a command
like the one below works nice:

riot -formatted=ttl prefixes.ttl in.nt > out.ttl

It is a big improvement. Is there perhaps a way to use @base too? If I put
@base in the prefixes.ttl file it seems to be ignored, just like a
specification of the base URI as a command line parameter.

Greetings,
Frans


On 6 September 2016 at 12:01, Andy Seaborne  wrote:

> Hi Frans,
>
> See "riot --help" for your version.
> https://jena.apache.org/documentation/io/#command-line-tools
>
> Currently:
>
> --output=FMT
>Output in the given format, streaming if possible.
> --formatted=FMT
> Output, using pretty printing (consumes memory)
> --stream=FMT
>Output, using a streaming format
>
> and make FMT "TTL"
>
> Note that --formatted (the prettiest) has to read all input into memory
> before printing begins which can be an issue at large scale, the other
> forms don't need this.
>
> To set particular prefixes when the data does provide them, add your own
> Turtle file with just prefixes in it.
>
> riot --formatted=TTL myprefixes.ttl data...data 2>/dev/null
>
> Andy
>
>
> On 06/09/16 10:38, Frans Knibbe wrote:
>
>> Hello,
>>
>> I use riot to convert RDF files to different formats on the command line.
>> It works well, but I wonder if there is an option to have @base and
>> @prefix
>> definitions in the output in turtle format. In many cases that would
>> result
>> in more compact files that are easier to read for humans.
>>
>> I can image riot could identify repeating URI prefixes itself, or perhaps
>> a
>> file with  @prefix definitions could be supplied as a parameter...
>>
>> As for @base, I see that there is a parameter --base=URI for riot. But
>> using it does not seem to give an @base in turtle output.
>>
>> Greetings,
>> Frans
>>
>>


Re: rdfs:comment

2016-09-08 Thread Sidra shah
Thanks a lot sir, I think the SPARQL CONSTRUCT is more suitable.

Regards

On Thu, Sep 8, 2016 at 3:27 AM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

> If you have a fixed set of resources, again I'd suggest to use SPARQL.
> Indeed, DBpedia also allows to download parts of the dataset, but I
> don't see any need to download the comments for all resources of DBpedia.
>
> In your case, use a SPARQL CONSTRUCT query which in fact returns plain
> RDF. Use this query once, save the file to the corresponding place and
> load this file then via Jena.
>
>
> On 08.09.2016 12:18, Sidra shah wrote:
> > Hello Lorenz sir, do we have some alternative way to get this like
> > downloading rdfs:comment of all resources from DBpedia and process it
> > locally?
> > Actually my data i-e about hundred cities are in the Arraylist and can be
> > accessed using loop so its not a straight forward way to access it via
> > endpoint.
> >
> > Regards
> >
> > On Thu, Sep 8, 2016 at 2:57 AM, Lorenz Buehmann <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >> But the data is contained in the SPARQL endpoint of DBpedia, isn't it?
> >> So how should it work without
> >>
> >> a) loading the necessary data in-memory - which in that case would also
> >> be your task to first get the data from the remote endpoint
> >>
> >> b) get the information from the remote endpoint via SPARQL
> >>
> >>
> >> On 07.09.2016 13:46, Sidra shah wrote:
> >>> Cant we access it through a Resource? If I include comment with every
> >>> instance of Question (Question is class name) like: What is capital of
> >>> Spain? here I include rdfs:comment of Madrid.
> >>> Which country has more population? here I include rdfs:comment of
> China.
> >>>
> >>> So later I set condition like if user did not answer the question
> >>> correctly, display rdfs:comment of that question.
> >>> if(Question.get(i).answer not correct) then
> Question.get(i).addcomment();
> >>>
> >>> addcomment() is a method of type Literal in Jena.
> >>>
> >>> On Wed, Sep 7, 2016 at 2:59 AM, Lorenz Buehmann <
> >>> buehm...@informatik.uni-leipzig.de> wrote:
> >>>
>  How many students of you are doing the same homework assignment?
> 
> 
>  Write a SPARQL query to get the rdfs:comment from the DBpedia
> endpoint.
> 
>  On 06.09.2016 14:17, Sidra shah wrote:
> > I have a question class in my ontolgy which have instance: What is
>  capital
> > city of Spain? I have then Answer class having instance Madrid along
> >> with
> > two other options London, Berlin. This is my owl file.
> >
> > Now in Jena/Java code, I want if user selects wrong option (not
> >> Madrid),
>  it
> > means user does not know about Madrid so I want to display him about
>  Madrid
> > a short details in shape of rdfs:comment Madrid.
> >
> > On Tue, Sep 6, 2016 at 3:53 AM, Lorenz Buehmann <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >> I don't understand what you are after.
> >>
> >>
> >> 1) This is not a Protege mailing list
> >> 2) http://dbpedia.org/Madrid is not a valid DBpedia URI
> >> 3) rdfs:comment could be retrieved by
> >> 3)a) SPARQL query
> >> 3)b) Load all triples about a particular resource, load those
> triples
> >> into Jena, use Jena RDF layer interface to get the information
> >> 4) I can't see the image, probably attachments are not allowed here
> >>
> >> Lorenz
> >>
> >> On 06.09.2016 12:43, Sidra shah wrote:
> >>> Hi
> >>>
> >>> How can we get the rdfs:comment of certain resource in dbpedia? I
> >> give
> >>> the address of resource in protege, but when I close it and open
> >>> again, the address changes again to my ontology address and under
> >>> comment Annotation only the address appears like
> >>> http://dbpedia.org/Madrid instead of the comments about Madrid
> >> city.?.
> >>> And how can we use this rdfs:comment in the jena code? Is it
> possible
> >>> to import the rdfs:comment details in our ontology and then access
> it
> >>> using Jena code?
> >>>
> >>> Inline image 1
> >>
>
>


Re: rdfs:comment

2016-09-08 Thread Lorenz Buehmann
If you have a fixed set of resources, again I'd suggest to use SPARQL.
Indeed, DBpedia also allows to download parts of the dataset, but I
don't see any need to download the comments for all resources of DBpedia.

In your case, use a SPARQL CONSTRUCT query which in fact returns plain
RDF. Use this query once, save the file to the corresponding place and
load this file then via Jena.


On 08.09.2016 12:18, Sidra shah wrote:
> Hello Lorenz sir, do we have some alternative way to get this like
> downloading rdfs:comment of all resources from DBpedia and process it
> locally?
> Actually my data i-e about hundred cities are in the Arraylist and can be
> accessed using loop so its not a straight forward way to access it via
> endpoint.
>
> Regards
>
> On Thu, Sep 8, 2016 at 2:57 AM, Lorenz Buehmann <
> buehm...@informatik.uni-leipzig.de> wrote:
>
>> But the data is contained in the SPARQL endpoint of DBpedia, isn't it?
>> So how should it work without
>>
>> a) loading the necessary data in-memory - which in that case would also
>> be your task to first get the data from the remote endpoint
>>
>> b) get the information from the remote endpoint via SPARQL
>>
>>
>> On 07.09.2016 13:46, Sidra shah wrote:
>>> Cant we access it through a Resource? If I include comment with every
>>> instance of Question (Question is class name) like: What is capital of
>>> Spain? here I include rdfs:comment of Madrid.
>>> Which country has more population? here I include rdfs:comment of China.
>>>
>>> So later I set condition like if user did not answer the question
>>> correctly, display rdfs:comment of that question.
>>> if(Question.get(i).answer not correct) then Question.get(i).addcomment();
>>>
>>> addcomment() is a method of type Literal in Jena.
>>>
>>> On Wed, Sep 7, 2016 at 2:59 AM, Lorenz Buehmann <
>>> buehm...@informatik.uni-leipzig.de> wrote:
>>>
 How many students of you are doing the same homework assignment?


 Write a SPARQL query to get the rdfs:comment from the DBpedia endpoint.

 On 06.09.2016 14:17, Sidra shah wrote:
> I have a question class in my ontolgy which have instance: What is
 capital
> city of Spain? I have then Answer class having instance Madrid along
>> with
> two other options London, Berlin. This is my owl file.
>
> Now in Jena/Java code, I want if user selects wrong option (not
>> Madrid),
 it
> means user does not know about Madrid so I want to display him about
 Madrid
> a short details in shape of rdfs:comment Madrid.
>
> On Tue, Sep 6, 2016 at 3:53 AM, Lorenz Buehmann <
> buehm...@informatik.uni-leipzig.de> wrote:
>
>> I don't understand what you are after.
>>
>>
>> 1) This is not a Protege mailing list
>> 2) http://dbpedia.org/Madrid is not a valid DBpedia URI
>> 3) rdfs:comment could be retrieved by
>> 3)a) SPARQL query
>> 3)b) Load all triples about a particular resource, load those triples
>> into Jena, use Jena RDF layer interface to get the information
>> 4) I can't see the image, probably attachments are not allowed here
>>
>> Lorenz
>>
>> On 06.09.2016 12:43, Sidra shah wrote:
>>> Hi
>>>
>>> How can we get the rdfs:comment of certain resource in dbpedia? I
>> give
>>> the address of resource in protege, but when I close it and open
>>> again, the address changes again to my ontology address and under
>>> comment Annotation only the address appears like
>>> http://dbpedia.org/Madrid instead of the comments about Madrid
>> city.?.
>>> And how can we use this rdfs:comment in the jena code? Is it possible
>>> to import the rdfs:comment details in our ontology and then access it
>>> using Jena code?
>>>
>>> Inline image 1
>>



Re: rdfs:comment

2016-09-08 Thread Sidra shah
Hello Lorenz sir, do we have some alternative way to get this like
downloading rdfs:comment of all resources from DBpedia and process it
locally?
Actually my data i-e about hundred cities are in the Arraylist and can be
accessed using loop so its not a straight forward way to access it via
endpoint.

Regards

On Thu, Sep 8, 2016 at 2:57 AM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

> But the data is contained in the SPARQL endpoint of DBpedia, isn't it?
> So how should it work without
>
> a) loading the necessary data in-memory - which in that case would also
> be your task to first get the data from the remote endpoint
>
> b) get the information from the remote endpoint via SPARQL
>
>
> On 07.09.2016 13:46, Sidra shah wrote:
> > Cant we access it through a Resource? If I include comment with every
> > instance of Question (Question is class name) like: What is capital of
> > Spain? here I include rdfs:comment of Madrid.
> > Which country has more population? here I include rdfs:comment of China.
> >
> > So later I set condition like if user did not answer the question
> > correctly, display rdfs:comment of that question.
> > if(Question.get(i).answer not correct) then Question.get(i).addcomment();
> >
> > addcomment() is a method of type Literal in Jena.
> >
> > On Wed, Sep 7, 2016 at 2:59 AM, Lorenz Buehmann <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >> How many students of you are doing the same homework assignment?
> >>
> >>
> >> Write a SPARQL query to get the rdfs:comment from the DBpedia endpoint.
> >>
> >> On 06.09.2016 14:17, Sidra shah wrote:
> >>> I have a question class in my ontolgy which have instance: What is
> >> capital
> >>> city of Spain? I have then Answer class having instance Madrid along
> with
> >>> two other options London, Berlin. This is my owl file.
> >>>
> >>> Now in Jena/Java code, I want if user selects wrong option (not
> Madrid),
> >> it
> >>> means user does not know about Madrid so I want to display him about
> >> Madrid
> >>> a short details in shape of rdfs:comment Madrid.
> >>>
> >>> On Tue, Sep 6, 2016 at 3:53 AM, Lorenz Buehmann <
> >>> buehm...@informatik.uni-leipzig.de> wrote:
> >>>
>  I don't understand what you are after.
> 
> 
>  1) This is not a Protege mailing list
>  2) http://dbpedia.org/Madrid is not a valid DBpedia URI
>  3) rdfs:comment could be retrieved by
>  3)a) SPARQL query
>  3)b) Load all triples about a particular resource, load those triples
>  into Jena, use Jena RDF layer interface to get the information
>  4) I can't see the image, probably attachments are not allowed here
> 
>  Lorenz
> 
>  On 06.09.2016 12:43, Sidra shah wrote:
> > Hi
> >
> > How can we get the rdfs:comment of certain resource in dbpedia? I
> give
> > the address of resource in protege, but when I close it and open
> > again, the address changes again to my ontology address and under
> > comment Annotation only the address appears like
> > http://dbpedia.org/Madrid instead of the comments about Madrid
> city.?.
> >
> > And how can we use this rdfs:comment in the jena code? Is it possible
> > to import the rdfs:comment details in our ontology and then access it
> > using Jena code?
> >
> > Inline image 1
> >>
>
>


Re: rdfs:comment

2016-09-08 Thread Lorenz Buehmann
But the data is contained in the SPARQL endpoint of DBpedia, isn't it?
So how should it work without

a) loading the necessary data in-memory - which in that case would also
be your task to first get the data from the remote endpoint

b) get the information from the remote endpoint via SPARQL


On 07.09.2016 13:46, Sidra shah wrote:
> Cant we access it through a Resource? If I include comment with every
> instance of Question (Question is class name) like: What is capital of
> Spain? here I include rdfs:comment of Madrid.
> Which country has more population? here I include rdfs:comment of China.
>
> So later I set condition like if user did not answer the question
> correctly, display rdfs:comment of that question.
> if(Question.get(i).answer not correct) then Question.get(i).addcomment();
>
> addcomment() is a method of type Literal in Jena.
>
> On Wed, Sep 7, 2016 at 2:59 AM, Lorenz Buehmann <
> buehm...@informatik.uni-leipzig.de> wrote:
>
>> How many students of you are doing the same homework assignment?
>>
>>
>> Write a SPARQL query to get the rdfs:comment from the DBpedia endpoint.
>>
>> On 06.09.2016 14:17, Sidra shah wrote:
>>> I have a question class in my ontolgy which have instance: What is
>> capital
>>> city of Spain? I have then Answer class having instance Madrid along with
>>> two other options London, Berlin. This is my owl file.
>>>
>>> Now in Jena/Java code, I want if user selects wrong option (not Madrid),
>> it
>>> means user does not know about Madrid so I want to display him about
>> Madrid
>>> a short details in shape of rdfs:comment Madrid.
>>>
>>> On Tue, Sep 6, 2016 at 3:53 AM, Lorenz Buehmann <
>>> buehm...@informatik.uni-leipzig.de> wrote:
>>>
 I don't understand what you are after.


 1) This is not a Protege mailing list
 2) http://dbpedia.org/Madrid is not a valid DBpedia URI
 3) rdfs:comment could be retrieved by
 3)a) SPARQL query
 3)b) Load all triples about a particular resource, load those triples
 into Jena, use Jena RDF layer interface to get the information
 4) I can't see the image, probably attachments are not allowed here

 Lorenz

 On 06.09.2016 12:43, Sidra shah wrote:
> Hi
>
> How can we get the rdfs:comment of certain resource in dbpedia? I give
> the address of resource in protege, but when I close it and open
> again, the address changes again to my ontology address and under
> comment Annotation only the address appears like
> http://dbpedia.org/Madrid instead of the comments about Madrid city.?.
>
> And how can we use this rdfs:comment in the jena code? Is it possible
> to import the rdfs:comment details in our ontology and then access it
> using Jena code?
>
> Inline image 1
>>



Re: Writing Jena Model to CSV

2016-09-08 Thread Nikolaos Beredimas
CSV is not a valid RDF serialization format as mentioned (only as a format
for SPARQL results).

If you want something similar to CSV for serializing an RDF Model, try
using N-triples.

On Thu, Sep 8, 2016 at 10:22 AM, Martynas Jusevičius 
wrote:

> I think CSV is for writing ResultSet (SELECT results), not Model
> (CONSTRUCT/DESCRIBE results).
>
> On Wed, 7 Sep 2016 at 23:37, lookman sanni  wrote:
>
> > Hi all,
> >
> > I am trying in vain to write a Jena model to a text file using
> > RDFDataMgr.write(outputstream, dataset2, lang).
> >
> > This works well for Lang such as RDFXML, TRIG, TURTLE, NQUADS. However
> for
> > Lang.CSV, it is firing a RiotException of which I have no idea:
> >
> >
> > *Exception in thread "main" org.apache.jena.riot.RiotException: No graph
> > writer for null*
> > * at
> > org.apache.jena.riot.RDFDataMgr.createGraphWriter$(
> RDFDataMgr.java:1199)*
> > * at org.apache.jena.riot.RDFDataMgr.write$(RDFDataMgr.java:1211)*
> > * at org.apache.jena.riot.RDFDataMgr.write(RDFDataMgr.java:1004)*
> > * at org.apache.jena.riot.RDFDataMgr.write(RDFDataMgr.java:995)*
> > * at org.apache.jena.riot.RDFDataMgr.write(RDFDataMgr.java:936)*
> > * at *
> >
> > Has anyone come across this in the past and has some hints on its why/how
> > to solve it ?
> >
> > Thanks, Lookman
> >
> > --
> > Best Regards
> >
> > Lookman SANNI
> >
>


Re: Writing Jena Model to CSV

2016-09-08 Thread Martynas Jusevičius
I think CSV is for writing ResultSet (SELECT results), not Model
(CONSTRUCT/DESCRIBE results).

On Wed, 7 Sep 2016 at 23:37, lookman sanni  wrote:

> Hi all,
>
> I am trying in vain to write a Jena model to a text file using
> RDFDataMgr.write(outputstream, dataset2, lang).
>
> This works well for Lang such as RDFXML, TRIG, TURTLE, NQUADS. However for
> Lang.CSV, it is firing a RiotException of which I have no idea:
>
>
> *Exception in thread "main" org.apache.jena.riot.RiotException: No graph
> writer for null*
> * at
> org.apache.jena.riot.RDFDataMgr.createGraphWriter$(RDFDataMgr.java:1199)*
> * at org.apache.jena.riot.RDFDataMgr.write$(RDFDataMgr.java:1211)*
> * at org.apache.jena.riot.RDFDataMgr.write(RDFDataMgr.java:1004)*
> * at org.apache.jena.riot.RDFDataMgr.write(RDFDataMgr.java:995)*
> * at org.apache.jena.riot.RDFDataMgr.write(RDFDataMgr.java:936)*
> * at *
>
> Has anyone come across this in the past and has some hints on its why/how
> to solve it ?
>
> Thanks, Lookman
>
> --
> Best Regards
>
> Lookman SANNI
>