owlcs / owlapi

OWL API main repository
822 stars 315 forks source link

`Individuals:` anonymous individuals in Manchester syntax #1006

Closed b-gehrke closed 2 years ago

b-gehrke commented 3 years ago

When loading an ontology which contains anonymous individuals and rendering it to functional syntax or manchester syntax the nodeIds of those individuals get replaced by _:genid<someNumber>. Why aren't the original nodeIds kept?

Furthermore, rendering in manchester Syntax introduces an Individuals: "axiom" (see example below). The standard doesn't define it. What does it mean and why is it used?

Example (taken from bioportal/BRIDG.owl)

<?xml version="1.0" encoding="UTF-8"?>
<owl:Ontology xmlns:owl="http://www.w3.org/2002/07/owl#">
  <owl:Prefix name="foaf" IRI="http://xmlns.com/foaf/0.1/"/>
  <owl:ClassAssertion>
    <owl:Class abbreviatedIRI="foaf:Organization"/>
    <owl:AnonymousIndividual nodeID="SCC"/>
  </owl:ClassAssertion>
  <owl:ClassAssertion>
    <owl:Class abbreviatedIRI="foaf:Organization"/>
    <owl:AnonymousIndividual nodeID="CDISC"/>
  </owl:ClassAssertion>
</owl:Ontology>

Rendered in manchester syntax

Prefix: owl: <http://www.w3.org/2002/07/owl#>
Prefix: rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
Prefix: rdfs: <http://www.w3.org/2000/01/rdf-schema#>
Prefix: xml: <http://www.w3.org/XML/1998/namespace>
Prefix: xsd: <http://www.w3.org/2001/XMLSchema#>

Ontology: 
Class: <http://xmlns.com/foaf/0.1/Organization>
    Individuals: 
        _:genid2147483648,
        _:genid2147483649
Individual: _:genid2147483648
    Types: 
        <http://xmlns.com/foaf/0.1/Organization>
Individual: _:genid2147483649
    Types: 
        <http://xmlns.com/foaf/0.1/Organization>

Rendered in functional syntax

Prefix(owl:=<http://www.w3.org/2002/07/owl#>)
Prefix(rdf:=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>)
Prefix(xml:=<http://www.w3.org/XML/1998/namespace>)
Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)
Prefix(foaf:=<http://xmlns.com/foaf/0.1/>)
Prefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)

Ontology(
Declaration(Class(foaf:Organization))

ClassAssertion(foaf:Organization _:genid2147483648)
ClassAssertion(foaf:Organization _:genid2147483649)
)
ignazio1977 commented 3 years ago

The original node ids are not kept because they are local to the file and keeping them means it's possible to get clashes between different files (e.g., when importing ontologies that lack an ontology declaration, where the contents of the file are meant to be inlined in the importing ontology).

The behaviour can be changed using ConfigurationOptions.REMAP_IDS and setting the property value for that option to false.

ignazio1977 commented 3 years ago

The Individuals: section appears to be just a list of individuals declared to have the class as one of their types (information duplicated in the individual declaration itself).

I'm not sure why it exists or why it's not defined in the standard; the renderer has been creating this section since I first started working on the OWLAPI, according to the history.

b-gehrke commented 3 years ago

Thank you for your responses. Regarding the Individuals: section: Would you say the renderer should be changed to not produce those section or should the standard be extended and define this section?

In my opinion the renderer should not create the section as the information is - as you said - just duplicated and can be expressed with the current standard.

ignazio1977 commented 3 years ago

I'm not sure of the intent and don't feel confident to say which is the bug - the code or the standard. Maybe @matthewhorridge has an opinion?