You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Wojciech Ciesielski <wo...@kierzbun.pl> on 2015/04/22 21:48:36 UTC
Problem with read/write N-Quads/TriG
Hi
On start sorry for my bad english.
I must do small example project for my study with read/write RDF graph
from file.
With Turtle,N-Triples, RDF/XML i dont have any problem i use:
FileManager.get().addLocatorClassLoader(Main.class.getClassLoader());
Model model = null;
try
{
model= FileManager.get().loadModel("./plik.ttl");
}
catch(Exception e)
{
System.out.println(e);
}
model.write(System.out,"TURTLE");
model.write(System.out,"N-TRIPLES");
model.write(System.out);
But when i try read TriG or N-Quads file
my file example (Da.txt):
<http://example/A> <http://example/B> <http://example/C>
<http://example/D> .
using:
Model nowy= FileManager.get().loadModel("./Da.txt", "N-QUADS");
nowy.write(System.out, "TRIG");
nowy.write(System.out, "NQUADS");
log4j: reset attribute= "false".
log4j: Threshold ="null".
log4j: Level value for root is [DEBUG].
log4j: root level set to DEBUG
log4j: Class name: [org.apache.log4j.ConsoleAppender]
log4j: Parsing layout of class: "org.apache.log4j.PatternLayout"
log4j: Setting property [conversionPattern] to [%d{yyyy-MM-dd HH:mm:ss}
%-5p %c{1}:%L - %m%n].
log4j: Adding appender named [console] to category [root].
2015-04-22 21:45:28 DEBUG JenaIOEnvironment:181 - Failed to find
configuration:
location-mapping.ttl;location-mapping.rdf;location-mapping.n3;etc/location-mapping.rdf;etc/location-mapping.n3;etc/location-mapping.ttl
2015-04-22 21:45:28 DEBUG FileManager:257 - loadModel(./plik.ttl)
2015-04-22 21:45:28 DEBUG StreamManager:112 - Not mapped: ./plik.ttl
2015-04-22 21:45:28 DEBUG StreamManager:93 - open(./plik.ttl)
2015-04-22 21:45:28 DEBUG StreamManager:112 - Not mapped: ./plik.ttl
2015-04-22 21:45:28 DEBUG StreamManager:142 - Found: ./plik.ttl
(LocatorFile)
2015-04-22 21:45:28 DEBUG RDFDataMgr:875 - Found: ./plik.ttl
2015-04-22 21:45:28 DEBUG FileManager:274 - loadModel(./Da.txt, N-QUADS)
2015-04-22 21:45:28 DEBUG StreamManager:112 - Not mapped: ./Da.txt
2015-04-22 21:45:28 DEBUG StreamManager:93 - open(./Da.txt)
2015-04-22 21:45:28 DEBUG StreamManager:112 - Not mapped: ./Da.txt
2015-04-22 21:45:28 DEBUG StreamManager:142 - Found: ./Da.txt (LocatorFile)
2015-04-22 21:45:28 DEBUG RDFDataMgr:875 - Found: ./Da.txt
2015-04-22 21:45:28 WARN riot:77 - Only triples or default graph data
expected : named graph data ignored
com.hp.hpl.jena.shared.NoWriterForLangException: TRIG
Im realy "green" in Jena and RDF.
I use Windows 7 64bit and NetBeans 8.0.2
Can someone explain me how to read/write N-Quads and TriG?
Realy thx for any anwser
--
Pozdrawiam
Wojciech Ciesielski
Re: Problem with read/write N-Quads/TriG
Posted by Wojciech Ciesielski <wo...@kierzbun.pl>.
Thx a lot
W dniu 2015-04-22 o 21:55, Martynas Jusevičius pisze:
> Model is for triples. You have to use Dataset for quads.
>
> https://jena.apache.org/documentation/javadoc/arq/com/hp/hpl/jena/query/Dataset.html
>
> On Wed, Apr 22, 2015 at 9:48 PM, Wojciech Ciesielski <wo...@kierzbun.pl> wrote:
>> Hi
>> On start sorry for my bad english.
>> I must do small example project for my study with read/write RDF graph from
>> file.
>> With Turtle,N-Triples, RDF/XML i dont have any problem i use:
>>
>> FileManager.get().addLocatorClassLoader(Main.class.getClassLoader());
>> Model model = null;
>> try
>> {
>> model= FileManager.get().loadModel("./plik.ttl");
>> }
>> catch(Exception e)
>> {
>> System.out.println(e);
>> }
>> model.write(System.out,"TURTLE");
>> model.write(System.out,"N-TRIPLES");
>> model.write(System.out);
>>
>> But when i try read TriG or N-Quads file
>> my file example (Da.txt):
>>
>> <http://example/A> <http://example/B> <http://example/C> <http://example/D>
>> .
>>
>> using:
>> Model nowy= FileManager.get().loadModel("./Da.txt", "N-QUADS");
>> nowy.write(System.out, "TRIG");
>> nowy.write(System.out, "NQUADS");
>>
>> log4j: reset attribute= "false".
>> log4j: Threshold ="null".
>> log4j: Level value for root is [DEBUG].
>> log4j: root level set to DEBUG
>> log4j: Class name: [org.apache.log4j.ConsoleAppender]
>> log4j: Parsing layout of class: "org.apache.log4j.PatternLayout"
>> log4j: Setting property [conversionPattern] to [%d{yyyy-MM-dd HH:mm:ss} %-5p
>> %c{1}:%L - %m%n].
>> log4j: Adding appender named [console] to category [root].
>> 2015-04-22 21:45:28 DEBUG JenaIOEnvironment:181 - Failed to find
>> configuration:
>> location-mapping.ttl;location-mapping.rdf;location-mapping.n3;etc/location-mapping.rdf;etc/location-mapping.n3;etc/location-mapping.ttl
>> 2015-04-22 21:45:28 DEBUG FileManager:257 - loadModel(./plik.ttl)
>> 2015-04-22 21:45:28 DEBUG StreamManager:112 - Not mapped: ./plik.ttl
>> 2015-04-22 21:45:28 DEBUG StreamManager:93 - open(./plik.ttl)
>> 2015-04-22 21:45:28 DEBUG StreamManager:112 - Not mapped: ./plik.ttl
>> 2015-04-22 21:45:28 DEBUG StreamManager:142 - Found: ./plik.ttl
>> (LocatorFile)
>> 2015-04-22 21:45:28 DEBUG RDFDataMgr:875 - Found: ./plik.ttl
>> 2015-04-22 21:45:28 DEBUG FileManager:274 - loadModel(./Da.txt, N-QUADS)
>> 2015-04-22 21:45:28 DEBUG StreamManager:112 - Not mapped: ./Da.txt
>> 2015-04-22 21:45:28 DEBUG StreamManager:93 - open(./Da.txt)
>> 2015-04-22 21:45:28 DEBUG StreamManager:112 - Not mapped: ./Da.txt
>> 2015-04-22 21:45:28 DEBUG StreamManager:142 - Found: ./Da.txt (LocatorFile)
>> 2015-04-22 21:45:28 DEBUG RDFDataMgr:875 - Found: ./Da.txt
>> 2015-04-22 21:45:28 WARN riot:77 - Only triples or default graph data
>> expected : named graph data ignored
>> com.hp.hpl.jena.shared.NoWriterForLangException: TRIG
>>
>> Im realy "green" in Jena and RDF.
>> I use Windows 7 64bit and NetBeans 8.0.2
>>
>> Can someone explain me how to read/write N-Quads and TriG?
>> Realy thx for any anwser
>>
>> --
>> Pozdrawiam
>> Wojciech Ciesielski
>>
>
> -----
> Nie znaleziono wirusów w tej wiadomości.
> Sprawdzone przez AVG - www.avg.com
> Wersja: 2015.0.5863 / Baza danych wirusów: 4334/9597 - Data wydania: 2015-04-22
>
>
>
--
Pozdrawiam
Wojciech Ciesielski
Re: Problem with read/write N-Quads/TriG
Posted by Wojciech Ciesielski <wo...@kierzbun.pl>.
Thx a lot
W dniu 2015-04-22 o 22:33, Andy Seaborne pisze:
> On 22/04/15 20:55, Martynas Jusevičius wrote:
>> Model is for triples. You have to use Dataset for quads.
>>
>> https://jena.apache.org/documentation/javadoc/arq/com/hp/hpl/jena/query/Dataset.html
>>
>
> Yes (you get only the default graph if you attempt to read into a model).
>
> Also:
>
> RDFDataMgr.loadDataset
> RDFDataMgr.write
>
> for dataset (and model) operations.
>
> Andy
>
>>
>> On Wed, Apr 22, 2015 at 9:48 PM, Wojciech Ciesielski
>> <wo...@kierzbun.pl> wrote:
>>> Hi
>>> On start sorry for my bad english.
>>> I must do small example project for my study with read/write RDF
>>> graph from
>>> file.
>>> With Turtle,N-Triples, RDF/XML i dont have any problem i use:
>>>
>>> FileManager.get().addLocatorClassLoader(Main.class.getClassLoader());
>>> Model model = null;
>>> try
>>> {
>>> model= FileManager.get().loadModel("./plik.ttl");
>>> }
>>> catch(Exception e)
>>> {
>>> System.out.println(e);
>>> }
>>> model.write(System.out,"TURTLE");
>>> model.write(System.out,"N-TRIPLES");
>>> model.write(System.out);
>>>
>>> But when i try read TriG or N-Quads file
>>> my file example (Da.txt):
>>>
>>> <http://example/A> <http://example/B> <http://example/C>
>>> <http://example/D>
>>> .
>>>
>>> using:
>>> Model nowy= FileManager.get().loadModel("./Da.txt", "N-QUADS");
>>> nowy.write(System.out, "TRIG");
>>> nowy.write(System.out, "NQUADS");
>>>
>>> log4j: reset attribute= "false".
>>> log4j: Threshold ="null".
>>> log4j: Level value for root is [DEBUG].
>>> log4j: root level set to DEBUG
>>> log4j: Class name: [org.apache.log4j.ConsoleAppender]
>>> log4j: Parsing layout of class: "org.apache.log4j.PatternLayout"
>>> log4j: Setting property [conversionPattern] to [%d{yyyy-MM-dd
>>> HH:mm:ss} %-5p
>>> %c{1}:%L - %m%n].
>>> log4j: Adding appender named [console] to category [root].
>>> 2015-04-22 21:45:28 DEBUG JenaIOEnvironment:181 - Failed to find
>>> configuration:
>>> location-mapping.ttl;location-mapping.rdf;location-mapping.n3;etc/location-mapping.rdf;etc/location-mapping.n3;etc/location-mapping.ttl
>>>
>>> 2015-04-22 21:45:28 DEBUG FileManager:257 - loadModel(./plik.ttl)
>>> 2015-04-22 21:45:28 DEBUG StreamManager:112 - Not mapped: ./plik.ttl
>>> 2015-04-22 21:45:28 DEBUG StreamManager:93 - open(./plik.ttl)
>>> 2015-04-22 21:45:28 DEBUG StreamManager:112 - Not mapped: ./plik.ttl
>>> 2015-04-22 21:45:28 DEBUG StreamManager:142 - Found: ./plik.ttl
>>> (LocatorFile)
>>> 2015-04-22 21:45:28 DEBUG RDFDataMgr:875 - Found: ./plik.ttl
>>> 2015-04-22 21:45:28 DEBUG FileManager:274 - loadModel(./Da.txt,
>>> N-QUADS)
>>> 2015-04-22 21:45:28 DEBUG StreamManager:112 - Not mapped: ./Da.txt
>>> 2015-04-22 21:45:28 DEBUG StreamManager:93 - open(./Da.txt)
>>> 2015-04-22 21:45:28 DEBUG StreamManager:112 - Not mapped: ./Da.txt
>>> 2015-04-22 21:45:28 DEBUG StreamManager:142 - Found: ./Da.txt
>>> (LocatorFile)
>>> 2015-04-22 21:45:28 DEBUG RDFDataMgr:875 - Found: ./Da.txt
>>> 2015-04-22 21:45:28 WARN riot:77 - Only triples or default graph data
>>> expected : named graph data ignored
>>> com.hp.hpl.jena.shared.NoWriterForLangException: TRIG
>>>
>>> Im realy "green" in Jena and RDF.
>>> I use Windows 7 64bit and NetBeans 8.0.2
>>>
>>> Can someone explain me how to read/write N-Quads and TriG?
>>> Realy thx for any anwser
>>>
>>> --
>>> Pozdrawiam
>>> Wojciech Ciesielski
>>>
>
>
>
> -----
> Nie znaleziono wirusów w tej wiadomości.
> Sprawdzone przez AVG - www.avg.com
> Wersja: 2015.0.5863 / Baza danych wirusów: 4334/9597 - Data wydania:
> 2015-04-22
>
>
--
Pozdrawiam
Wojciech Ciesielski
Re: Problem with read/write N-Quads/TriG
Posted by Andy Seaborne <an...@apache.org>.
On 22/04/15 20:55, Martynas Jusevičius wrote:
> Model is for triples. You have to use Dataset for quads.
>
> https://jena.apache.org/documentation/javadoc/arq/com/hp/hpl/jena/query/Dataset.html
Yes (you get only the default graph if you attempt to read into a model).
Also:
RDFDataMgr.loadDataset
RDFDataMgr.write
for dataset (and model) operations.
Andy
>
> On Wed, Apr 22, 2015 at 9:48 PM, Wojciech Ciesielski <wo...@kierzbun.pl> wrote:
>> Hi
>> On start sorry for my bad english.
>> I must do small example project for my study with read/write RDF graph from
>> file.
>> With Turtle,N-Triples, RDF/XML i dont have any problem i use:
>>
>> FileManager.get().addLocatorClassLoader(Main.class.getClassLoader());
>> Model model = null;
>> try
>> {
>> model= FileManager.get().loadModel("./plik.ttl");
>> }
>> catch(Exception e)
>> {
>> System.out.println(e);
>> }
>> model.write(System.out,"TURTLE");
>> model.write(System.out,"N-TRIPLES");
>> model.write(System.out);
>>
>> But when i try read TriG or N-Quads file
>> my file example (Da.txt):
>>
>> <http://example/A> <http://example/B> <http://example/C> <http://example/D>
>> .
>>
>> using:
>> Model nowy= FileManager.get().loadModel("./Da.txt", "N-QUADS");
>> nowy.write(System.out, "TRIG");
>> nowy.write(System.out, "NQUADS");
>>
>> log4j: reset attribute= "false".
>> log4j: Threshold ="null".
>> log4j: Level value for root is [DEBUG].
>> log4j: root level set to DEBUG
>> log4j: Class name: [org.apache.log4j.ConsoleAppender]
>> log4j: Parsing layout of class: "org.apache.log4j.PatternLayout"
>> log4j: Setting property [conversionPattern] to [%d{yyyy-MM-dd HH:mm:ss} %-5p
>> %c{1}:%L - %m%n].
>> log4j: Adding appender named [console] to category [root].
>> 2015-04-22 21:45:28 DEBUG JenaIOEnvironment:181 - Failed to find
>> configuration:
>> location-mapping.ttl;location-mapping.rdf;location-mapping.n3;etc/location-mapping.rdf;etc/location-mapping.n3;etc/location-mapping.ttl
>> 2015-04-22 21:45:28 DEBUG FileManager:257 - loadModel(./plik.ttl)
>> 2015-04-22 21:45:28 DEBUG StreamManager:112 - Not mapped: ./plik.ttl
>> 2015-04-22 21:45:28 DEBUG StreamManager:93 - open(./plik.ttl)
>> 2015-04-22 21:45:28 DEBUG StreamManager:112 - Not mapped: ./plik.ttl
>> 2015-04-22 21:45:28 DEBUG StreamManager:142 - Found: ./plik.ttl
>> (LocatorFile)
>> 2015-04-22 21:45:28 DEBUG RDFDataMgr:875 - Found: ./plik.ttl
>> 2015-04-22 21:45:28 DEBUG FileManager:274 - loadModel(./Da.txt, N-QUADS)
>> 2015-04-22 21:45:28 DEBUG StreamManager:112 - Not mapped: ./Da.txt
>> 2015-04-22 21:45:28 DEBUG StreamManager:93 - open(./Da.txt)
>> 2015-04-22 21:45:28 DEBUG StreamManager:112 - Not mapped: ./Da.txt
>> 2015-04-22 21:45:28 DEBUG StreamManager:142 - Found: ./Da.txt (LocatorFile)
>> 2015-04-22 21:45:28 DEBUG RDFDataMgr:875 - Found: ./Da.txt
>> 2015-04-22 21:45:28 WARN riot:77 - Only triples or default graph data
>> expected : named graph data ignored
>> com.hp.hpl.jena.shared.NoWriterForLangException: TRIG
>>
>> Im realy "green" in Jena and RDF.
>> I use Windows 7 64bit and NetBeans 8.0.2
>>
>> Can someone explain me how to read/write N-Quads and TriG?
>> Realy thx for any anwser
>>
>> --
>> Pozdrawiam
>> Wojciech Ciesielski
>>
Re: Problem with read/write N-Quads/TriG
Posted by Martynas Jusevičius <ma...@graphity.org>.
Model is for triples. You have to use Dataset for quads.
https://jena.apache.org/documentation/javadoc/arq/com/hp/hpl/jena/query/Dataset.html
On Wed, Apr 22, 2015 at 9:48 PM, Wojciech Ciesielski <wo...@kierzbun.pl> wrote:
> Hi
> On start sorry for my bad english.
> I must do small example project for my study with read/write RDF graph from
> file.
> With Turtle,N-Triples, RDF/XML i dont have any problem i use:
>
> FileManager.get().addLocatorClassLoader(Main.class.getClassLoader());
> Model model = null;
> try
> {
> model= FileManager.get().loadModel("./plik.ttl");
> }
> catch(Exception e)
> {
> System.out.println(e);
> }
> model.write(System.out,"TURTLE");
> model.write(System.out,"N-TRIPLES");
> model.write(System.out);
>
> But when i try read TriG or N-Quads file
> my file example (Da.txt):
>
> <http://example/A> <http://example/B> <http://example/C> <http://example/D>
> .
>
> using:
> Model nowy= FileManager.get().loadModel("./Da.txt", "N-QUADS");
> nowy.write(System.out, "TRIG");
> nowy.write(System.out, "NQUADS");
>
> log4j: reset attribute= "false".
> log4j: Threshold ="null".
> log4j: Level value for root is [DEBUG].
> log4j: root level set to DEBUG
> log4j: Class name: [org.apache.log4j.ConsoleAppender]
> log4j: Parsing layout of class: "org.apache.log4j.PatternLayout"
> log4j: Setting property [conversionPattern] to [%d{yyyy-MM-dd HH:mm:ss} %-5p
> %c{1}:%L - %m%n].
> log4j: Adding appender named [console] to category [root].
> 2015-04-22 21:45:28 DEBUG JenaIOEnvironment:181 - Failed to find
> configuration:
> location-mapping.ttl;location-mapping.rdf;location-mapping.n3;etc/location-mapping.rdf;etc/location-mapping.n3;etc/location-mapping.ttl
> 2015-04-22 21:45:28 DEBUG FileManager:257 - loadModel(./plik.ttl)
> 2015-04-22 21:45:28 DEBUG StreamManager:112 - Not mapped: ./plik.ttl
> 2015-04-22 21:45:28 DEBUG StreamManager:93 - open(./plik.ttl)
> 2015-04-22 21:45:28 DEBUG StreamManager:112 - Not mapped: ./plik.ttl
> 2015-04-22 21:45:28 DEBUG StreamManager:142 - Found: ./plik.ttl
> (LocatorFile)
> 2015-04-22 21:45:28 DEBUG RDFDataMgr:875 - Found: ./plik.ttl
> 2015-04-22 21:45:28 DEBUG FileManager:274 - loadModel(./Da.txt, N-QUADS)
> 2015-04-22 21:45:28 DEBUG StreamManager:112 - Not mapped: ./Da.txt
> 2015-04-22 21:45:28 DEBUG StreamManager:93 - open(./Da.txt)
> 2015-04-22 21:45:28 DEBUG StreamManager:112 - Not mapped: ./Da.txt
> 2015-04-22 21:45:28 DEBUG StreamManager:142 - Found: ./Da.txt (LocatorFile)
> 2015-04-22 21:45:28 DEBUG RDFDataMgr:875 - Found: ./Da.txt
> 2015-04-22 21:45:28 WARN riot:77 - Only triples or default graph data
> expected : named graph data ignored
> com.hp.hpl.jena.shared.NoWriterForLangException: TRIG
>
> Im realy "green" in Jena and RDF.
> I use Windows 7 64bit and NetBeans 8.0.2
>
> Can someone explain me how to read/write N-Quads and TriG?
> Realy thx for any anwser
>
> --
> Pozdrawiam
> Wojciech Ciesielski
>