blake-regalia / graphy.js

A collection of RDF libraries for JavaScript
https://graphy.link/
ISC License
161 stars 3 forks source link

Possible issue parsing LODCloud_SPARQL_Endpoints.ttl #21

Closed happybeing closed 4 years ago

happybeing commented 4 years ago

I'm seeing an issue parsing the following file from a browser app:

https://github.com/OpenLinkSoftware/lod-cloud/blob/master/LODCloud_SPARQL_Endpoints.ttl (reported as https://github.com/OpenLinkSoftware/lod-cloud/issues/1)

I have a local copy, and if I import it as follows, and pass this as text to ttl_reader() it parses ok. import lodCloudRdf from '../data/LODCloud_SPARQL_Endpoints.ttl';

Whereas in a browser app if I select the file using HTML <input> and use the resulting File.text() object I get the following error. I have other files which parse by either method, so I think it is a combination of this particular file and some quirk in my code or in graphy.

So I wonder if you can try loading the file into graphy yourself (from a local git cloned copy if possible).

main.js:851 Uncaught Error: invalid IRI: "http://data.openlinksw.com/oplweb/sparql-endpoint1#this
    void:triples      "http://aemet.linkeddata.es/sparql/" ;
    a                sd:Service ;
    schema:publisher <http://aemet.linkeddata.es//#webid"
    at Reader.error (main.js:851)
    at Reader.check_named_node_escapeless (main.js:548)
    at Reader.statement [as _f_state] (main.js:1040)
    at Reader.post_object [as after_end_of_statement] (main.js:2963)
    at Reader.safe_parse (main.js:821)
    at Turtle_Reader.transform [as _transform] (main.js:672)
    at Turtle_Reader../node_modules/@graphy/core.iso.stream/node_modules/readable-stream/lib/_stream_transform.js.Transform._read (_stream_transform.js:177)
    at Turtle_Reader../node_modules/@graphy/core.iso.stream/node_modules/readable-stream/lib/_stream_transform.js.Transform._write (_stream_transform.js:164)
    at doWrite (_stream_writable.js:405)
    at writeOrBuffer (_stream_writable.js:394)
namedgraph commented 4 years ago

The file is broken: https://github.com/OpenLinkSoftware/lod-cloud/blob/master/LODCloud_SPARQL_Endpoints.ttl#L320 missing >

namedgraph commented 4 years ago

https://github.com/OpenLinkSoftware/lod-cloud/issues/3

blake-regalia commented 4 years ago

Unfortunately, I see invalid generated Turtle documents in the wild more often than I'd expect.

For future reference: Although the following solution is far from ideal, if you simply need to recover invalid documents ASAP, you can try passing the relax option to the reader, which will try its best to ignore bad tokens (however, it would not recover from this particular syntax error).

blake-regalia commented 4 years ago

Closing as this seems to be an error in the Turtle document.