spdx / spdx/spec-parser

Difficult to determine enumeration types from generated OWL/SHACL file

Open
#163 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
11
Forks
13
PR merge metrics
No merged PRs in 30d

Description

Context: to generate the Java code from the OWL/SHACL file, we need to determine if a particular class is an enumeration type

Based on the information available in the OWL/SHACL file, we would have to find all property references to the class and do some rather messy heuristics to determine if a particular class is an Enum class.

Suggestion is to add some information at the class level to more accurately and easily determine if a class represents an Enum with a limited range of values.

Currently, it looks like the only hints as to whether a class is an Enum class is in the properties whose range is that class.

Details:

The current generated file only has basic information for a class containing only enumerated values. For example, HashAlgorithm is defined only containing the comment:

ns2:HashAlgorithm a owl:Class ;
    rdfs:comment "A mathematical algorithm that maps data of arbitrary size to a bit string."@en .

The individuals defined for that class can be a hint, but they only have a label and a comment. Example:

<https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/adler32> a owl:NamedIndividual,
        ns2:HashAlgorithm ;
    rdfs:label "adler32" ;
    rdfs:comment "Adler-32 checksum is part of the widely used zlib compression library as defined in [RFC 1950](https://datatracker.ietf.org/doc/rfc1950/) Section 2.3."@en .

The properties which are limited to the class do provide a restriction which can be useful.

Example:

ns2:Hash a owl:Class,
        sh:NodeShape ;
    rdfs:comment "A mathematically calculated representation of a grouping of data."@en ;
    rdfs:subClassOf ns2:IntegrityMethod ;
    sh:nodeKind sh:BlankNode ;
    sh:property [ sh:datatype xsd:string ;
            sh:maxCount 1 ;
            sh:minCount 1 ;
            sh:nodeKind sh:Literal ;
            sh:path ns2:hashValue ],
        [ sh:class ns2:HashAlgorithm ;
            sh:in ( <https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/adler32> <https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake2b256> <https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake2b384> <https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake2b512> <https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake3> <https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/crystalsDilithium> <https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/crystalsKyber> <https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/falcon> <https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/md2> <https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/md4> <https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/md5> <https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/md6> <https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/other> <https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha1> <https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha224> <https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha256> <https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha384> <https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha512> <https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_224> <https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_256> <https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_384> <https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_512> ) ;
            sh:maxCount 1 ;
            sh:minCount 1 ;
            sh:nodeKind sh:IRI ;
            sh:path ns2:algorithm ] .

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the spec-parser generation flow and the OWL/SHACL examples in the issue, especially the HashAlgorithm class and the Hash property restriction. Determine how a class-level enum marker should be represented and how generated Java code can consume it; done means enum classes can be identified without property-reference heuristics.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, python
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.