Skip to content

rdf to-jelly: support generalized RDF input#98

Merged
Ostrzyciel merged 3 commits intomainfrom
88-add-support-for-generalized-rdf-input
Apr 25, 2025
Merged

rdf to-jelly: support generalized RDF input#98
Ostrzyciel merged 3 commits intomainfrom
88-add-support-for-generalized-rdf-input

Conversation

@Ostrzyciel
Copy link
Member

@Ostrzyciel Ostrzyciel commented Apr 25, 2025

Resolves: #88

We basically spin our own versions of NT and NQ parsers that can ingest generalized RDF, and then we re-register them in Jena as the only NT/NQ parsers.

I don't think there is an easier way to achieve this. The checks disallowing generalized RDF are hardcoded into the parsers.

@Ostrzyciel Ostrzyciel linked an issue Apr 25, 2025 that may be closed by this pull request
@Ostrzyciel Ostrzyciel marked this pull request as draft April 25, 2025 16:58
@Ostrzyciel Ostrzyciel marked this pull request as ready for review April 25, 2025 18:33
Copy link
Collaborator

@Karolina-Bogacka Karolina-Bogacka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, this looks a bit hacky to me, but I trust that there is no other way to support these functionalities.


protected final def parseTripleTermGeneralized: Node =
val t = parseTripleGeneralized
val x = nextToken
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why value names like x or t, this is not very informative

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the original names from Jena... let's go with that for now.

val ds = DatasetGraphFactory.create()
RDFParser.source(newIn).lang(JellyLanguage.JELLY).parse(ds)
ds.size() should be(4) // 4 named graphs
ds.getDefaultGraph.size() should be(4) // 4 triples in the default graph
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test seems kind of roundabout to me. Why do we have a separate test nq file only to check at the end the number of quads? wouldn't it make more sense to create an nq file dynamically from a set of statements and then compare the final graph to the first set of statements, or try to translate the above graph to nquad and compare the two .nq files/strings?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point is to just check if the parser works. Generating this dynamically is a pain, I'd prefer to have it in a file.

@Ostrzyciel Ostrzyciel merged commit 237204a into main Apr 25, 2025
7 checks passed
@Ostrzyciel Ostrzyciel deleted the 88-add-support-for-generalized-rdf-input branch April 25, 2025 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for generalized RDF input

2 participants