fix(generators): add --normalize-prefixes flag for well-known prefix names#4
Open
fix(generators): add --normalize-prefixes flag for well-known prefix names#4
Conversation
42e007b to
71db97f
Compare
…names Add an opt-in --normalize-prefixes flag to OWL, SHACL, and JSON-LD Context generators that normalises non-standard prefix aliases to rdflib's curated default names (e.g. sdo -> schema for schema.org). When enabled: - OWL/SHACL generators use override=False on graph.bind() so that rdflib's default prefix bindings take precedence over schema aliases - ContextGenerator remaps non-standard prefix names to their standard equivalents and applies the remap consistently to CURIE generation The flag defaults to off, preserving existing behaviour. Tests verify flag-on remapping (dce -> dc, sdo -> schema), CURIE consistency, and flag-off backward compatibility. Signed-off-by: jdsika <carlo.van-driesten@bmw.de>
71db97f to
e987cd8
Compare
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.
Summary
Add an opt-in
--normalize-prefixesflag to all generators that normalises non-standard prefix aliases to rdflib's curated default names (e.g.sdo→schemaforhttps://schema.org/).Motivation
Schemas often declare custom prefix aliases for well-known namespaces (e.g.
sdoforhttps://schema.org/,dceforhttp://purl.org/dc/elements/1.1/). When generated artifacts are consumed by tools that expect conventional prefix names, this causes friction. This flag allows opt-in normalization without changing default behavior.Changes
generator.py: Addwell_known_prefix_map()utility that returns rdflib's curated namespace-to-prefix mapping. Addnormalize_prefixesfield toGeneratorbase class and--normalize-prefixes/--no-normalize-prefixesCLI flag.owlgen.py: Gategraph.bind(..., override=False)behind the flag so rdflib's default prefix names take precedence only when enabled.shaclgen.py: Same gating for SHACL graph prefix binding.jsonldcontextgen.py: When flag is set, remap non-standard prefix aliases to standard names in the namespace dict and apply the remap consistently to CURIE generation in_build_element_id().Backward Compatibility
The flag defaults to off — existing behavior is fully preserved. No snapshot updates required.