feat(dtypes): langstring — sprach-getaggte Strings (rdf:langString)#85
Merged
Conversation
Neuer dtype langstring + Wertklasse LangString(text, lang). In JSON-LD ueber @language ausgedrueckt (nicht @type): {"@value": "Hallo", "@language": "de"} — also korrektes rdf:langString. Kompakte Textform "text@lang" ("Hallo@de"). Coercion: LangString-Passthrough, (text, lang)-Tupel/Liste, {"@value","@language"}- Dict, oder String mit endstaendigem BCP-47-Tag (ambig "a@b.com" -> kein Tag); leer/None -> None. Registry-Key "langstring" (resolve lowercased -> "langString" funktioniert auch). DTYPES_INV, json_default, to_json (-> "Hallo@de") angebunden. semantic.py: _value_literal rendert langstring via @language (mit/ohne Tag); _set_from_node liest @language zurueck und rekonstruiert text@lang. Ohne Sprach-Tag degradiert ein langstring sauber zu str (rdf:langString verlangt ein Tag). Tests: Coercion (alle Eingabeformen), LangString-Klasse (eq/hash/str/repr), to_json, json_default, resolve/xsd, JSON- und JSON-LD-Round-Trip (mit und ohne Tag). dtypes.py 307/307 100%, semantic.py 100%. Doku + CHANGELOG [1.3.0] ergaenzt. Kanonische CI: 620 passed, 7 skipped, TOTAL 100%; mkdocs --strict gruen.
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| Documentation | 8 minor |
🟢 Metrics 28 complexity · 0 duplication
Metric Results Complexity 28 Duplication 0
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
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.
Was
Neuer dtype
langstring+ WertklasseLangString(text, lang)fürsprach-getaggte Strings (i18n-Labels). Der Sonderfall unter den dtypes: in JSON-LD
über
@languageausgedrückt (nicht@type):Coercion
LangString-Passthrough ·(text, lang)-Tupel/Liste ·{"@value","@language"}-Dict ·String mit endständigem BCP-47-Tag (
"Hallo@de","Hello@en-US"). Mehrdeutiges"a@b.com"→ kein Tag (BCP-47-Validierung am Ende); leer/None→None.JSON-LD (semantic.py)
_value_literal: rendertlangstringvia@language(mit/ohne Tag)_set_from_node: liest@languagezurück und rekonstruierttext@langlangstringsauber zustr(rdf:langString verlangtein Tag)
Anbindung
DTYPES_INV(LangString→langstring),json_default,DtypeSpec.to_json(
→ "Hallo@de"), Registry-Keylangstring(resolve lowercased →dtype="langString"funktioniert ebenfalls).
Tests / CI
tests/test_dtypes.py: Coercion (alle Eingabeformen + Ambiguität),LangString-Klasse(
eq/hash/str/repr),to_json,json_default,resolve/xsd, JSON- undJSON-LD-Round-Trip (mit und ohne Tag).
dtypes.py307/307 100 %,semantic.py100 %.Kanonische CI: 620 passed, 7 skipped, TOTAL 100 %;
mkdocs build --strictgrün.Doku + CHANGELOG [1.3.0] ergänzt.