Fix roundtrip lang literal conversion#146
Merged
kisoso merged 3 commits intoVisualMeaning:masterfrom Feb 16, 2026
Merged
Conversation
kisoso
commented
Feb 11, 2026
sheet_to_triples/tests/test_rdf.py
Outdated
| '"path\\\\with\\\\backslashes"@en'), | ||
| (rdflib.Literal('mixed: "quotes"\nand newlines\tand tabs', lang='en'), | ||
| '"mixed: \\"quotes\\"\\nand newlines\\tand tabs"@en'), | ||
| (rdflib.Literal('\u043e', lang='bg'), '"\\u043e"@bg'), |
Contributor
Author
There was a problem hiding this comment.
Only this test is updated.
kisoso
commented
Feb 11, 2026
| @@ -422,3 +427,32 @@ def test_from_identifier_lang_obj(self): | |||
| self.resolver.from_identifier('{"k": "v"}@en'), | |||
| rdflib.Literal('{"k": "v"}', lang='en') | |||
Contributor
Author
There was a problem hiding this comment.
Should this actually need to resolve to rdflib.Literal({"k": "v"}, lang='en') ?
Member
There was a problem hiding this comment.
Likely not - RDF literals don't have a dict type really.
bz2
approved these changes
Feb 16, 2026
sheet_to_triples/tests/test_rdf.py
Outdated
| (rdflib.Literal('mixed: "quotes"\nand newlines\tand tabs', lang='en'), | ||
| '"mixed: \\"quotes\\"\\nand newlines\\tand tabs"@en'), | ||
| (rdflib.Literal('\u043e', lang='bg'), '"\\u043e"@bg'), | ||
| (rdflib.Literal('л', lang='bg'), '"\\u043b"@bg'), |
Member
There was a problem hiding this comment.
This test is just the same as the one above now, but for the source code spelling?
sheet_to_triples/tests/test_rdf.py
Outdated
| (rdflib.Literal('{"o": "v"}', lang='en'), '{"o": "v"}@en'), | ||
| ] | ||
| triples = [('_s', '_p', obj) for obj, _ in test_cases] | ||
| expected = [exp for _, exp in test_cases] |
Member
There was a problem hiding this comment.
Could use subTest() if structuring like the this.
https://docs.python.org/3/library/unittest.html#distinguishing-test-iterations-using-subtests
Contributor
Author
There was a problem hiding this comment.
Yep, will just revert.
| @@ -422,3 +427,32 @@ def test_from_identifier_lang_obj(self): | |||
| self.resolver.from_identifier('{"k": "v"}@en'), | |||
| rdflib.Literal('{"k": "v"}', lang='en') | |||
Member
There was a problem hiding this comment.
Likely not - RDF literals don't have a dict type really.
| ] | ||
|
|
||
| for text, lang in test_texts: | ||
| with self.subTest(text=text, lang=lang): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For localized string
literal.n3()might not be the best representation in json model.For example, the output of Cyrillic
оis'"\u043b"@bg'The proposed casting to term.obj resolves to
'"\\u043b"@bg'(the language tagged string is serialized) which is more inline with how we feed the string to transform (.as_json- applyingjson.dumps()) and how it is consumed (JSON.parse()). The simplest way of converting any datatype into a string is stringifying it.The more important bit is the casting being invertible, allowing a process where a runner outputs a model.json that is sequentially used as input for a second run. Each time converting data to rdflib entities then exported to model.json in string format.
https://visual-meaning.atlassian.net/browse/SMP-3764
@VisualMeaning/devs