Skip to content

Conversation

aucampia
Copy link
Member

@aucampia aucampia commented Jun 20, 2023

  • Literal's datatype attribute is now no longer optional and will never
    be None.
  • Constructing a literal with only a language tag will set the datatype
    to rdf:langString.

Related issues:

WhiteGobo and others added 3 commits August 16, 2023 22:12
Raise an error when nested graphs occur in TriG.

With this change, the <http://www.w3.org/2013/TriGTests/#trig-graph-bad-07> test passes.

---------

Co-authored-by: WhiteGobo <richardfechner@posteo.net>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Iwan Aucamp <aucampia@gmail.com>
Skip the following tests that rely on SPARQL 1.0 grammar
and are incompatible with the SPARQL 1.1 grammar:

- <http://www.w3.org/2001/sw/DataAccess/tests/data-r2/basic/manifest#term-6>
- <http://www.w3.org/2001/sw/DataAccess/tests/data-r2/basic/manifest#term-7>

---------

Co-authored-by: WhiteGobo <richardfechner@posteo.net>
Co-authored-by: Iwan Aucamp <aucampia@gmail.com>
TBD

checkpoint

aucampia/20230609T2355-literal_datatype: checkpoint 20230817T000443
Comment on lines +714 to +728
if lang is not None or datatype == _RDF_LANGSTRING:
if lang is None:
raise ValueError(f"language cannot be None if datatype is {datatype}")
if not lang:
raise ValueError("language cannot be empty string")
if not _lang_tag_regex.match(lang):
raise ValueError(
"language tag must match the pattern "
"^[a-zA-Z]+(?:-[a-zA-Z0-9]+)*$ "
f"but was {lang}"
)

if datatype is None:
datatype = _RDF_LANGSTRING

Copy link
Contributor

@WhiteGobo WhiteGobo Sep 25, 2023

Choose a reason for hiding this comment

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

Let q=Literal("ex", datatype=something). This will also overwrite any datatype given to a new Literal Literal(q, lang="en").

#prevous:
Literal(q, lang="en")
# >> Literal("ex", lang="en", datatype=something)

# now:
Literal(q, lang="en")
# >> Literal("ex", lang="en", datatype=RDF.langString)

Before the datatype was inherited. But i havent seen this behaviour documented, so there was no expected behaviour before. But we could mention this change in behaviour nonetheless.
Also this will handle issue #2603

_XSD_PFX = "http://www.w3.org/2001/XMLSchema#"
_RDF_PFX = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"

_RDF_LANGSTRING = URIRef(_RDF_PFX + "langString")
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be more useful to make _RDF_LANGSTRING a class attribute for Literal. Then someone can change the default datatype for langstring by using a childclass instead of changing it programwide.
But im not sure

@nicholascar
Copy link
Member

@WhiteGobo @aucampia are either of you likely to be able to update / improve this PR?

@ashleysommer
Copy link
Contributor

I'd like to see this merged after the release of v7.1.0, along with this related change #2866 as part of the "lots of breaking changes" release that RDFLib-8 will be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants