Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 423: Add JSON-LD context dictionary generator #453

Draft
wants to merge 50 commits into
base: develop
Choose a base branch
from

Conversation

kfairbanks
Copy link
Contributor

@kfairbanks kfairbanks commented Aug 16, 2022

This Pull Request resolves all requirements of Issue #423 .

Coordination

  • Pull Request is against correct branch
  • Pull Request is in, or reverted to, Draft status before Solutions Approval vote has passed.
  • CI passes in (CASE/UCO) feature branch
  • CI passes in UCO current unstable branch (merge-commit)
  • CI passes in CASE current unstable branch tracking UCO's unstable as submodule (merge-commit)
  • Impact on SHACL validation reviewed for CASE-Examples
  • Impact on SHACL validation remediated for CASE-Examples
  • Impact on SHACL validation reviewed for casework.github.io
  • Impact on SHACL validation remediated for casework.github.io
  • Milestone linked
  • Solutions Approval vote logged on corresponding Issue (once logged, can be taken out of Draft PR status)

kfairbanks and others added 25 commits August 5, 2022 09:18
Changes how prefixes are parsed
Changes key terms at end of context
Changes how shacl nodes are found
Signed-off-by: Alex Nelson <[email protected]>
Signed-off-by: Alex Nelson <[email protected]>
@kfairbanks kfairbanks marked this pull request as ready for review August 17, 2022 17:46
@ajnelson-nist ajnelson-nist linked an issue Aug 17, 2022 that may be closed by this pull request
11 tasks
This is the result of working through a few rounds of `mypy --strict`,
which now passes when rdflib >= 6.2.0 is installed in the virtual
environment.

Some minor logic errors were caught.  At least one significant error was
found and flagged.

References:
* ucoProject#423

Signed-off-by: Alex Nelson <[email protected]>
Test known to fail currently.

References:
* ucoProject#423

Signed-off-by: Alex Nelson <[email protected]>
This is another necessary proof of functionality for the testing.

References:
* ucoProject#423

Signed-off-by: Alex Nelson <[email protected]>
Signed-off-by: Alex Nelson <[email protected]>
Signed-off-by: Alex Nelson <[email protected]>
@ajnelson-nist
Copy link
Contributor

@kfairbanks - I inlined a TODO that you might need to address, about keying some dicts. I'm not sure; your dictionary generator seems to be working well enough now w.r.t. collecting properties.

Your method for building the namespace prefixes looks like it would benefit from a stably-available prefix definition, rather than needing to crawl through /ontology. (At the time you call the generators, uco_monolithic.ttl happens to guarantee to have been built, which would also lend to saving you from a os.walk().) It's probably worth the committee considering using sh:declares or skos:notation to house authoritative prefixes.

All of the ontologies under /ontology/uco/ currently have an rdfs:label you could use. (This turns out to be sufficient coverage, because ontologies under the other /ontology directories don't define things that need to go into a context dictionary.) But, semantics for rdfs:label don't necessarily encourage the kind of consumption and availability-guarantee that you'd want. If you'd like to help justify prefixes and shave away ~50 lines of code, feel free to take inspiration from this SPARQL query:

SELECT ?nOntology ?lLabel
WHERE {
  ?nOntology a owl:Ontology .
  OPTIONAL {
    ?nOntology rdfs:label ?lLabel .
  }
}
ORDER BY ?nOntology

Meanwhile: I've added a test for the "Concise" dictionary form. It currently fails, and reviewing the generated file, I see the issue is that classes are not being generated for either dictionary form. I was surprised that the "Minimal" JSON-LD sample was working with both the "minimal" and "concise" context dictionaries. The reason that worked was that the classes that weren't in the context dictionary were inlined in each of the nodes.

I also added tests for whether UCO properties and datatype annotations (UCO-sourced and XSD-sourced) were getting picked up by the dictionaries, by adapting the tests/examples/hash_PASS.json file. That file's small enough it wasn't too painful to add a full IRI expansion of everything and do an exact set-of-triples comparison. The verbose pytest output is pretty instructive - run make check and you'll see.

The last test, which I'm not sure can be run from pyshacl's command line interface, is SHACL validation using a context dictionary. It might be necessary to consider SHACL validation out of scope of this test suite. (case_validate can add a flag to load some context dictionary, but for a test to run in UCO, something would probably have to be written, re-implementing a chunk of case_validate for the sake of the test suite only.)

Next steps: Please get make check to pass; it'll be up to the committee to handle the prefixes question. Getting there might be all that's necessary.

@ajnelson-nist ajnelson-nist added this to the UCO 1.0.0 milestone Aug 18, 2022
@ajnelson-nist
Copy link
Contributor

Converting to Draft until Solutions Approval vote is logged.

@ajnelson-nist ajnelson-nist marked this pull request as draft August 21, 2022 15:45
@ajnelson-nist ajnelson-nist changed the title Issue 423 Issue 423: Add JSON-LD context dictionary generator Aug 23, 2022
ajnelson-nist and others added 15 commits August 23, 2022 11:21
…dictionary

I had previously realized, and forgotten, that datatyped literals do not
appear to be supported as a feature within context dictionaries.

References:
* ucoProject#423

Signed-off-by: Alex Nelson <[email protected]>
Signed-off-by: Alex Nelson <[email protected]>
Signed-off-by: Alex Nelson <[email protected]>
This is to account for classes that UCO imports from external
ontologies.

This patch is necessary, but insufficient, to fix the thread test.

Signed-off-by: Alex Nelson <[email protected]>
@ajnelson-nist ajnelson-nist modified the milestones: UCO 1.0.0, UCO 1.x.0 Aug 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add JSON-LD context for serialized UCO content
2 participants