pietercolpaert / hardf

Low level PHP library for RDF1.1 based on N3.js
https://packagist.org/packages/pietercolpaert/hardf
MIT License
36 stars 7 forks source link

Parsing n-triples is faulty => Exception: Unexpected "typeIRI" on line 1. #26

Closed k00ni closed 6 years ago

k00ni commented 6 years ago

hardf seems to have a hard time parsing triples like:

<http://example.org/show/218> <http://www.w3.org/2000/01/rdf-schema#label> "That Seventies Show"^^<http://www.w3.org/2001/XMLSchema#string> .
<http://example.org/show/218> <http://www.w3.org/2000/01/rdf-schema#label> "That Seventies Show" .
<http://example.org/show/218> <http://example.org/show/localName> "That Seventies Show"@en .
<http://example.org/show/218> <http://example.org/show/localName> "Cette Série des Années Septante"@fr-be .
<http://example.org/#spiderman> <http://example.org/text> "Multi-line\nliteral with many quotes (\"\"\"\"\")\nand two apostrophes ('')." .
<http://en.wikipedia.org/wiki/Helium> <http://example.org/elements/atomicNumber> "2"^^<http://www.w3.org/2001/XMLSchema#integer> .
<http://en.wikipedia.org/wiki/Helium> <http://example.org/elements/specificGravity> "1.663E-4"^^<http://www.w3.org/2001/XMLSchema#double> .

Source: https://www.w3.org/TR/n-triples/#sec-literals (removed the comments)

I always get the following error:

Exception: Unexpected "typeIRI" on line 1.

/app/src/Saft/Addition/hardf/vendor/pietercolpaert/hardf/src/N3Lexer.php:411
/app/src/Saft/Addition/hardf/vendor/pietercolpaert/hardf/src/N3Lexer.php:41
/app/src/Saft/Addition/hardf/vendor/pietercolpaert/hardf/src/N3Lexer.php:441
/app/src/Saft/Addition/hardf/vendor/pietercolpaert/hardf/src/TriGParser.php:986
/app/src/Saft/Addition/hardf/vendor/pietercolpaert/hardf/src/TriGParser.php:969

Test setup

$parser = new TriGParser([
    'format' => 'triple'
]);

$str = '<http://example.org/show/218> <http://www.w3.org/2000/01/rdf-schema#label> "That Seventies Show"^^<http://www.w3.org/2001/XMLSchema#string> .
';
$parser->parse($str);
// $parser->parseChunk($str); also fails

Any idea? @pietercolpaert

pietercolpaert commented 6 years ago

@k00ni probably because of $parser = new TriGParser(['format' => 'triple')); → triple is not a known format. Can you test this again with turtle?

k00ni commented 6 years ago

Currently very busy, but will test it later. Sorry for the delayed answer.