Problem loading simple ntriples file

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem loading simple ntriples file

moissinac
Hello
I'm testing owlready2 which seems interesting.
But, I'm encoutering problem with the loading phase of one of my files with
senneville_ontology= get_ontology("file://c://wamp64/www/barbules/ontologies/test.nt").load()
where test.nt contains only one line
<http://barbules.givingsense.eu/ontologies/barbules/SENNEVILLE> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#NamedIndividual> .
I'm getting the following error:
...
File "C:\wamp64\www\CPD\trials\venv\lib\site-packages\owlready2\rdfxml_2_ntriples.py", line 315, in parse
raise OwlReadyOntologyParsingError("RDF/XML parsing error in file %s, line %s, column %s." % (getattr(f, "name", getattr(f, "url", "???")), parser.CurrentLineNumber, parser.CurrentColumnNumber)) from e
owlready2.base.OwlReadyOntologyParsingError: RDF/XML parsing error in file c://wamp64/www/barbules/ontologies/test.nt, line 1, column 7.
So, the file is recognized as being an N-triples file, but the parser fails to parse it.
Reply | Threaded
Open this post in threaded view
|

Re: Problem loading simple ntriples file

franzlst
I had a similar error recently and got the impression that the N-triples parser hasn't been tested for quite some time. If you have a very simple N-triples files, you might succeed if you remove all occurrences of '.decode("utf8")', e.g. this one, as this is not Python 3 compatible.
Reply | Threaded
Open this post in threaded view
|

Re: Problem loading simple ntriples file

Jiba
Administrator
In reply to this post by moissinac
Hello,

Your file is NOT recognized as being an N-triples file : rdfxml_2_ntriples.py is not a NTriple parser, but an RDF/XML parser that produce a pseudo NTriple as output.

Owlready consider an NTriple file as a file having a . at the end of its first line. Possibly you have some comment or empty lines at the beginning of the file ?

I will modify the development version of Owlready to make it more tolerant to empty lines at the beginning of the file.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Problem loading simple ntriples file

Jiba
Administrator
In reply to this post by franzlst
I do not understand the problem with '.decode("utf8")' ? The file is opened in binary mode, thus yielding Python bytes, which have the .decode() method :

>>> b"xxx".decode
<built-in method decode of bytes object at 0x7fb958b74030>

Jiba