Repository navigation
feat(ontology): add an optional document-level language tag - #689
rodrigo-fagundes wants to merge 2 commits into
Conversation
|
Thank you for your first contribution to Apache Ossie (incubating)! A committer will review your PR. In the meantime, please ensure:
No ICLA is required to contribute. If you are elected as a committer in the future, you will need an Individual Contributor License Agreement (ICLA) on file with the ASF. Questions? Ask in the PR comments or join us on Slack. We appreciate your contribution! |
orca-review-bot
left a comment
There was a problem hiding this comment.
Nice, tight addition. The pattern does what the PR says, the tests pin exactly one pattern error per rejection, and adding to the 0.2.0.dev0 history entry matches what #400 and #458 did. Main ask: the doc should say "well-formed" BCP 47, since registry validity isn't checked. Optional: add language: en to examples/flights.ontology.yaml so CI runs the field on a real document. For the core-spec follow-up, can we share this pattern as one $def so the two copies don't drift?
🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.
| description: "A generic agent (person, organization, etc.)" | ||
| ``` | ||
|
|
||
| The value is a language tag as defined by [BCP 47](https://www.rfc-editor.org/info/bcp47) |
There was a problem hiding this comment.
The schema only checks the tag's shape, so xx and qua pass even though they aren't registered subtags. Can we say "a well-formed BCP 47 tag" here and add that subtags aren't checked against the IANA registry?
🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.
| "language": { | ||
| "type": "string", | ||
| "pattern": "^(?!(und|mul|zxx|mis|q[a-t][a-z])(-|$))[a-z]{2,3}(-[A-Z][a-z]{3})?(-([A-Z]{2}|[0-9]{3}))?$", | ||
| "maxLength": 35, |
There was a problem hiding this comment.
This limit never applies, because the pattern already caps tags at 12 chars. Can we drop it, or note in the PR that it's there for later widening?
🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.
| assert not _only_min_length_paths(ontology_validator, document) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("language", ["en", "pt-BR", "zh-Hant-TW", "es-419", "fil"]) |
There was a problem hiding this comment.
Can we add en-Latn-US here so all three subtags are covered together? A matching abcde in the rejected list would pin the {2,3} length.
🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.
3df6eff to
831a4c7
Compare
An ontology's descriptions and verbalizations are written in a natural language, but no field says which one. Annotations could hold it, but the spec does not interpret them, so each tool would choose its own key. Consumers that need the language (OPC UA LocalizedText, RDF language-tagged literals, AI tools) had to guess. Add an optional root `language`: a BCP 47 (RFC 5646) tag restricted to language, optional script and optional region, in canonical case, so that tags compare as plain strings. Tags that name no single language (und, mul, zxx, mis, and the private-use range qaa-qtz) are rejected. The tag covers descriptions, verbalizations and ai_context, and never identifiers. An absent tag means the language is not stated, so every existing document still validates. Generated-by: Claude Code (claude-opus-5-5)
Say that the tag is well-formed and that subtags are not checked against the IANA registry. Drop maxLength, which the pattern's 12 characters already make unreachable. Cover language, script and region on an English tag, and pin both ends of the language subtag's length. State the language in both flights ontology examples, which a test keeps equal. Since the branch was opened, main gained the Python ontology models and annotations. Add the field to OssieOntologyModel, which mirrors the schema, with the pattern pinned to the schema's. State that the language does not cover annotations, which the spec does not interpret. Generated-by: Claude Code (claude-opus-5-5)
831a4c7 to
8e863d3
Compare
Summary
An ontology document is written in a natural language, but it cannot say which one. Descriptions
explain concepts in prose, and every relationship's required
verbalizesreadings are sentences.No field records the language.
annotationscould hold it, but the spec does not interpret them, soeach tool would choose its own key and others could not rely on it. Consumers that need the language
(OPC UA LocalizedText, RDF language-tagged literals, AI tools, translation workflows) have to guess.
This PR adds one optional field:
The
[DISCUSS]thread on dev@ossie.apache.org has not been started yet; its link will go here.What changes
ontology/ontology.jsonlanguage: a string matching a well-formed BCP 47 (RFC 5646) tag of language, optional script and optional region, in canonical caseontology/ontology.mdpython/src/ossie/models.pyand its testslanguageonOssieOntologyModel, which mirrors the schema; a test pins its pattern to the schema'sexamples/flights.yaml,examples/flights.ontology.yamllanguage: en, in both because a test keeps them equalvalidation/tests/test_ontology.pypatternerror onlanguageThe tag pattern:
en,pt-BR,zh-Hant-TW,en-Latn-US,es-419,fil;pt-brandEN(not canonical case),en_US,en-,en-US-x-private(subtags outsidethe restricted shape),
english,eandabcd(wrong length), and the tags that name no single language:und,mul,zxx,misandqst(private use).Design notes
language, notlocale. It states the language of content. A locale is a set of userpreferences (W3C, Language Tags and Locale Identifiers, §2–3). This matches RDF, JSON-LD
@language,xml:langand DCAT.stay possible later.
the language, so the field has no effect on resolution or validation beyond its own value.
that consumes these tags uses. Widening it later does not break any document.
Compatibility
Purely additive. Every document that validates today still validates, and an absent
languagemeans "not stated".
Testing
Follow-up
If the shape is accepted, a second PR adds the same field to semantic models (
core-spec).Tooling
Prepared with Claude Code; the commits carry a
Generated-by:token, per the ASF Generative Tooling Guidance.