Skip to content

Context file: Set @type to @id for terms that refer to a class #204

Description

@bact

In the context file, use @id as the @type for any term where the range is a class.

For example, for createBy, which its range is Agent class, its entry in context file should look like this:

    "createdBy": {
      "@id": "https://spdx.org/rdf/3.1/terms/Core/createdBy",
      "@type": "@id"
    },

Currently we set the type as @vocab, but Agent is not a vocabulary.

Propose to change these lines:

elif (o, RDF.type, OWL.Class) in g:
return {
"@id": subject,
"@type": "@vocab",
}

to:

        elif (o, RDF.type, OWL.Class) in g:
            return {
                "@id": subject,
                "@type": "@id",
            }

o here is not a vocabulary, because line 268, and it is a class, because line 276:

for _, _, o in g.triples((subject, RDFS.range, None)):
if o in vocab_classes:
return {
"@id": subject,
"@type": "@vocab",
"@context": {
"@vocab": o + "/",
},
}
elif (o, RDF.type, OWL.Class) in g:
return {
"@id": subject,
"@type": "@vocab",
}

Ref: spdx/spdx-3-model#1167

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions