RDF/XML or Turtle ontology fails to load with urlencode error

658 views
Skip to first unread message

mishra...@gmail.com

unread,
May 5, 2013, 5:31:31 PM5/5/13
to rdfli...@googlegroups.com
Note: I'm new to RDF and relatively new to Python.

I'm working on an ontology and while trying to load it via rdflib I get the following error:
"D:\Interest_Turtle.ttl does not look like a valid URI, perhaps you want to urlencode it?"

The ontology loads fine in the Protege ontology editor from Stanford and the rdf translator (http://rdf-translator.appspot.com/) is able to convert it to JSON so I'm not sure what's wrong.

Any help is appreciated. I've copied the Traceback below.

On a side note, is there a command line tool available to convert RDF/XML or Turtle to JSON?

>>>

Traceback (most recent call last):
File "D:\ontology_rdf.py", line 64, in <module>
main()
File "D:\ontology_rdf.py", line 47, in main
h.load('Interest_Turtle.ttl', format='ttl')
File "build\bdist.win-amd64\egg\rdflib\graph.py", line 1012, in load
self.parse(source, publicID, format)
File "build\bdist.win-amd64\egg\rdflib\graph.py", line 1000, in parse
data=data, format=format)
File "build\bdist.win-amd64\egg\rdflib\parser.py", line 171, in create_input_source
input_source = FileInputSource(file)
File "build\bdist.win-amd64\egg\rdflib\parser.py", line 116, in __init__
system_id = URIRef(file.name, base=base)
File "build\bdist.win-amd64\egg\rdflib\term.py", line 204, in __new__
raise Exception('%s does not look like a valid URI, perhaps you want to urlencode it?'%value)
Exception: D:\Interest_Turtle.ttl does not look like a valid URI, perhaps you want to urlencode it?

Gunnar Aastrand Grimnes

unread,
May 6, 2013, 4:55:39 AM5/6/13
to rdfli...@googlegroups.com
This one is all my fault - good catch.

It's a side effect of
https://github.com/RDFLib/rdflib/commit/d3ff38cb0a6b1ab41796248cd55d7f09eeda02f2

which tried to address:

https://github.com/RDFLib/rdflib/issues/266

I will come up with a proper solution - but for now you can install
the commit just before that:

https://github.com/RDFLib/rdflib/archive/2165ed98c9927a565646c59376941f2624c976c3.zip

(or just use release 3.4)

- Gunnar
> --
> http://github.com/RDFLib
> ---
> You received this message because you are subscribed to the Google Groups "rdflib-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rdflib-dev+...@googlegroups.com.
> To post to this group, send email to rdfli...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msg/rdflib-dev/-/PUwYzD2jcX4J.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
http://gromgull.net

Gunnar Aastrand Grimnes

unread,
May 8, 2013, 4:38:21 PM5/8/13
to rdfli...@googlegroups.com
Sorry for the delay, I had to find a windows machine.

I believe I've fixed this issue here:

https://github.com/RDFLib/rdflib/commit/05b0a4ae9a46e04eed136838f0bcf3e7d1849ed0

If would be great if you could reinstall the HEAD of the master branch
and try again!

Cheers,

- Gunnar

On 5 May 2013 23:31, <mishra...@gmail.com> wrote:

mishra...@gmail.com

unread,
May 8, 2013, 10:49:33 PM5/8/13
to rdfli...@googlegroups.com
Thanx a lot for the quick turnaround!

rdflib doesn't like TTL but OWL is loading. I need to run some tests to see if things are good.

For TTL:
"No plugin registered for (ttl, <class 'rdflib.parser.Parser'>)"

TRACEBACK:
>>> ================================ RESTART ================================
>>>

Traceback (most recent call last):

File "D:\rdf.py", line 57, in <module>
main()
File "D:\rdf.py", line 39, in main
h.load('D:\Interest_Turtle.ttl', format='ttl')
File "build\bdist.win-amd64\egg\rdflib\graph.py", line 1040, in load
self.parse(source, publicID, format)
File "build\bdist.win-amd64\egg\rdflib\graph.py", line 1035, in parse
parser = plugin.get(format, Parser)()
File "build\bdist.win-amd64\egg\rdflib\plugin.py", line 103, in get
"No plugin registered for (%s, %s)" % (name, kind))
PluginException: No plugin registered for (ttl, <class 'rdflib.parser.Parser'>)

Gunnar Aastrand Grimnes

unread,
May 9, 2013, 1:41:49 AM5/9/13
to rdfli...@googlegroups.com
rdflib loves turtle, you just have to call it by it's name, not the extension :)

h.load('my file.ttl', format='turtle')

You can use the guess_format function to map from extension to format:

http://rdflib.readthedocs.org/en/latest/apidocs/rdflib.html#rdflib.util.guess_format

- Gunnar
> To view this discussion on the web visit https://groups.google.com/d/msg/rdflib-dev/-/mN4k3S0-YXUJ.

Niklas Lindström

unread,
May 9, 2013, 6:32:13 AM5/9/13
to rdfli...@googlegroups.com
Ah, nice to see this. It used to be in the rdfextras package, but I've figured it would be good to incorporate it into rdflib proper.

Even more, I wonder if it would be useful to use it by default? That is, do not expect RDF/XML if a format can be guessed from the path suffix. Or at least to do this if format=None is used.

(Granted, for one it needs a bit of refactoring to avoid a circular import between graph.py and util.py. And more crucially, the guess_format should be reconciled with the format plugin architecture, along with the mime-type support in parser.URLInputSource (and similar support in the pyRdfa.utils.URLInputSource). It fear it's in a state of disarray.)

Cheers,
Niklas

Gunnar Aastrand Grimnes

unread,
May 9, 2013, 6:55:14 AM5/9/13
to rdfli...@googlegroups.com
On 9 May 2013 12:32, Niklas Lindström <linds...@gmail.com> wrote:
>
> (Granted, for one it needs a bit of refactoring to avoid a circular import
> between graph.py and util.py. And more crucially, the guess_format should be
> reconciled with the format plugin architecture, along with the mime-type
> support in parser.URLInputSource (and similar support in the
> pyRdfa.utils.URLInputSource). It fear it's in a state of disarray.)

the soon to be released v4 is the time to break things - pull requests
are welcome! :)

- Gunnar


--
http://gromgull.net
Reply all
Reply to author
Forward
0 new messages