ontodev / robot

ROBOT is an OBO Tool
http://robot.obolibrary.org
BSD 3-Clause "New" or "Revised" License
264 stars 74 forks source link

Duplicating classes when merging #1116

Open luisramosbosch opened 1 year ago

luisramosbosch commented 1 year ago

I am using the lcc ontology to add geo features to Germany.

I was able to add the corresponding geo feature, but found out that the rdf:type reference is being duplicated, I mean in the source ontology there is only one reference to country, while in the output ontology appear two reference to country to the individual Germany:

image

Here is the template, and I wonder why the reference should being duplicated?

CURIE Label Type Comment hasGeometry Geometry ID LABEL TYPE A rdfs:comment AI geosparql:hasGeometry AT geosparql:asWKT^^geosparql:wktLiteral loc:germany-geometry Germany Geometry sf:MultiPolygon Multipolygon representing the Federal Republic of Germany POINT(2.2945 48.8584) lcc-3166-1:Germany https://www.omg.org/spec/LCC/Countries/CountryRepresentation/Country http://www.example.com/germany-geometry

Luis Ramos

jamesaoverton commented 1 year ago

Sorry that you're having problems. There isn't enough information here to debug the problem. I suspect that you are using more than one IRI for "country", but I can't tell from the links you provided.

luisramosbosch commented 1 year ago

this is the command I am using: robot template --prefix "loc: http://www.example.com/" ^ --prefix "geosparql: http://www.opengis.net/ont/geosparql#" ^ --prefix "sf: http://www.opengis.net/ont/sf#" ^ --prefix "lcc-3166-1: https://www.omg.org/spec/LCC/Countries/ISO3166-1-CountryCodes/" ^ --merge-before ^ --input ISO3166-2-SubdivisionCodes-DE.rdf ^ --template geo-de_germany.tsv ^ --output test-germany.owl

luisramosbosch commented 1 year ago

and this is the full output ontology: <?xml version="1.0"?> <rdf:RDF xmlns="https://www.omg.org/spec/LCC/Countries/Regions/ISO3166-2-SubdivisionCodes-DE/" xml:base="https://www.omg.org/spec/LCC/Countries/Regions/ISO3166-2-SubdivisionCodes-DE/" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xsd="http://www.w3.org/2001/XMLSchema#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:terms="http://purl.org/dc/terms/" xmlns:geosparql="http://www.opengis.net/ont/geosparql#" xmlns:CountryRepresentation="https://www.omg.org/spec/LCC/Countries/CountryRepresentation/" xmlns:SpecificationMetadata="http://www.omg.org/techprocess/ab/SpecificationMetadata/" xmlns:LanguageRepresentation="https://www.omg.org/spec/LCC/Languages/LanguageRepresentation/">

2021-10-30T01:57:18.464529+02:00 http://opensource.org/licenses/MIT https://www.w3.org/TR/owl2-quick-reference/ Copyright (c) 2015-2017 Unisys Copyright (c) 2015-2020 Adaptive Inc. Copyright (c) 2015-2021 Object Management Group, Inc. Copyright (c) 2015-2021 Thematix Partners LLC Copyright (c) 2021 agnos.ai UK Ltd. https://www.omg.org/spec/LCC/Countries/CountryRepresentation/ https://www.omg.org/spec/LCC/Countries/ISO3166-1-CountryCodes/ https://www.omg.org/spec/LCC/Countries/ISO3166-2-SubdivisionCodes/ https://www.omg.org/spec/LCC/Languages/LanguageRepresentation/ lcc-3166-2-de This ontology represents the subset of the ISO 3166 standard that includes the actual ISO 3166-2 subdivision codes for Germany, with the ontology and codes for the other parts of the standard represented in models that this ontology depends on. ISO3166-2-SubdivisionCodes-DE.rdf ISO 3166-2 Subdivision Codes for Germany Ontology POINT(2.2945 48.8584) Multipolygon representing the Federal Republic of Germany Germany Geometry Land subdivision category Land in the country of Germany DE-BB DE-BB subdivision code for the Land of Brandenburg in the country of Germany Brandenburg Brandenburg the Land of Brandenburg in the country of Germany DE-BE DE-BE subdivision code for the Land of Berlin in the country of Germany Berlin Berlin the Land of Berlin in the country of Germany DE-BW DE-BW subdivision code for the Land of Baden-Württemberg in the country of Germany Baden-Württemberg Baden-Württemberg the Land of Baden-Württemberg in the country of Germany DE-BY DE-BY subdivision code for the Land of Bayern in the country of Germany Bayern Bayern the Land of Bayern in the country of Germany DE-HB DE-HB subdivision code for the Land of Bremen in the country of Germany Bremen Bremen the Land of Bremen in the country of Germany DE-HE DE-HE subdivision code for the Land of Hessen in the country of Germany Hessen Hessen the Land of Hessen in the country of Germany DE-HH DE-HH subdivision code for the Land of Hamburg in the country of Germany Hamburg Hamburg the Land of Hamburg in the country of Germany DE-MV DE-MV subdivision code for the Land of Mecklenburg-Vorpommern in the country of Germany Mecklenburg-Vorpommern Mecklenburg-Vorpommern the Land of Mecklenburg-Vorpommern in the country of Germany DE-NI DE-NI subdivision code for the Land of Niedersachsen in the country of Germany Niedersachsen Niedersachsen the Land of Niedersachsen in the country of Germany DE-NW DE-NW subdivision code for the Land of Nordrhein-Westfalen in the country of Germany Nordrhein-Westfalen Nordrhein-Westfalen the Land of Nordrhein-Westfalen in the country of Germany DE-RP DE-RP subdivision code for the Land of Rheinland-Pfalz in the country of Germany Rheinland-Pfalz Rheinland-Pfalz the Land of Rheinland-Pfalz in the country of Germany DE-SH DE-SH subdivision code for the Land of Schleswig-Holstein in the country of Germany Schleswig-Holstein Schleswig-Holstein the Land of Schleswig-Holstein in the country of Germany DE-SL DE-SL subdivision code for the Land of Saarland in the country of Germany Saarland Saarland the Land of Saarland in the country of Germany DE-SN DE-SN subdivision code for the Land of Sachsen in the country of Germany Sachsen Sachsen the Land of Sachsen in the country of Germany DE-ST DE-ST subdivision code for the Land of Sachsen-Anhalt in the country of Germany Sachsen-Anhalt Sachsen-Anhalt the Land of Sachsen-Anhalt in the country of Germany DE-TH DE-TH subdivision code for the Land of Thüringen in the country of Germany Thüringen Thüringen the Land of Thüringen in the country of Germany
luisramosbosch commented 1 year ago

Sorry that you're having problems. There isn't enough information here to debug the problem. I suspect that you are using more than one IRI for "country", but I can't tell from the links you provided.

actually that seems to be the case, but I am not doing that in the template (or at least i don't think so), and that is the question. I am indicating Germany is of type Country, no more.

jamesaoverton commented 1 year ago

lcc-3166-1:Germany has a single rdf:type in this output, as specified in the template. I also looked in the source ontology you linked https://www.omg.org/spec/LCC/20211101/Countries/Regions/ISO3166-2-SubdivisionCodes-DE.rdf and I didn't see lcc-3166-1:Germany or https://www.omg.org/spec/LCC/Countries/CountryRepresentation/Country mentioned there at all.

luisramosbosch commented 1 year ago

and Germany just exists, thus I wonder if there is another way to create an individual, and relate it to another existing one without producing such unwanted result?.

luisramosbosch commented 1 year ago

lcc-3166-1:Germany has a single rdf:type in this output, as specified in the template. I also looked in the source ontology you linked https://www.omg.org/spec/LCC/20211101/Countries/Regions/ISO3166-2-SubdivisionCodes-DE.rdf and I didn't see lcc-3166-1:Germany or https://www.omg.org/spec/LCC/Countries/CountryRepresentation/Country mentioned there at all.

With regard to this comment, so it is the modular structure of LCC - OMG spec, if I get your point. And, as you say, lcc-3166-1:Germany has a single rdf:type, but the output produces duplicated references, and that is what I wonder: why?.

jamesaoverton commented 1 year ago

Now I see where the other rdf:type assertion is coming from. The type IRI is indeed the same.

So I think that this is just how Protege is displaying the fact that the rdf:type is asserted in the file you're loading (bold) and in one of the imports (not bold). If you merge all the imports and save to a new file, you should not see duplicate rdf:type.

To avoid this, in your template row for lcc-3166-1:Germany try setting the type to owl:Individual or maybe owl:NamedIndividual instead of Country.

luisramosbosch commented 1 year ago

Hi dear, I solved most issues using owl:NamedIndividual and the Country reference to Germany is not duplicated anymore. But, however it continues duplicating the states reference:

image

which is even stranger, given that I do not mention this identifier in this template.

The template with German states would be like:

CURIE Label Type Comment hasGeometry Geometry ID LABEL TYPE A rdfs:comment AI geosparql:hasGeometry AT geosparql:asWKT^^geosparql:wktLiteral loc:germany-geometry Germany Geometry sf:MultiPolygon Multipolygon representing the Federal Republic of Germany POINT(2.2945 48.8584) lcc-3166-1:Germany owl:NamedIndividual http://www.example.com/germany-geometry loc:Baden-Württemberg-geometry Baden-Württemberg Geometry sf:MultiPolygon Multipolygon representing the german state of Baden-Württemberg POINT(2.2945 48.8584) lcc-3166-2-DE:DE-BW-Subdivision owl:NamedIndividual http://www.example.com/Baden-Württemberg-geometry
loc:Bayern-geometry Bayern Geometry sf:Polygon Multipolygon representing the german state of Bayern POINT(2.2945 48.8584)

Thanks for all your support

Luis Ramos

luisramosbosch commented 1 year ago

let me know if you need the full ontology

jamesaoverton commented 1 year ago

Maybe it's because you're using owl:sameAs. I would avoid that if possible.