Removing class annotations from owl ontology if included in a separated import - owl

I have a "core" ontology (core.owl) in which I import a separated online ontology (imports.owl) using Protégé, ending up with a declaration in header
<Import>https://raw.githubusercontent.com/...../imports.owl</Import>
Some classes are found both in core.owl and in imports.owl, to structure the final hierarchy. Unfortunately in both ontologies they also include annotations (such as rdfs:label) resulting in the duplication of a number of annotations in the final ontology, which is no good (for example, violates the OBO profile) and is what I'd like to solve.
Could anyone suggest methods to:
identify classes in both ontologies
remove all annotations those classes have in the core.owl ontology

Related

Add imports in OWLAPI

I'd like to check the consistency of a number of triples by using a reasoner.
There are around 700k triples to check, so for each of them I created a file with the triple and the direct types of its subject and object.
My problem is that if I don't import all the properties everytime I load one of the small file, all ObjectProperty statements are treated as AnnotationAxioms, which doesn't allow to spot any inconsistency.
How can I import all the properties just once and add them to the file with the triples everytime I load one?
Thanks in advance!
Edit
I add here an example of the small files I am analysing.
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
xmlns:wdt="http://www.wikidata.org/prop/direct/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="http://www.wikidata.org/entity/Q295376">
<rdf:type rdf:resource="http://www.wikidata.org/entity/Q5"/>
</rdf:Description>
<rdf:Description rdf:about="http://www.wikidata.org/entity/Q21077119">
<rdf:type rdf:resource="http://www.wikidata.org/entity/Q17299750"/>
<wdt:P1346 rdf:resource="http://www.wikidata.org/entity/Q295376"/>
<rdf:type rdf:resource="http://www.wikidata.org/entity/Q4993329"/>
</rdf:Description>
</rdf:RDF>
The above lines do not include the import axioms.
Thanks!
It will be much faster to not write the triple to disk. Create tee ontology with declarations for the properties and then add the axiom you wish to test. You can then create the reasoner, test for consistency, discard the reasoner and remove the axiom you just tested. The ontology is then available to be used with another axiom and a new reasoner.
However, you're checking each axiom in isolation; while the axioms might be consistent on their own, this does not provide assurances as to what the axioms will do together - assuming that they will appear in the same ontology after you finish your test.
Specifically on how to add an import to an ontology, see the OWLAPI documentation at https://github.com/owlcs/owlapi/wiki/Add-an-import-directive-to-an-ontology
I don't believe that's the best solution to your scenario, but it's the question you asked :-)

How to import specific classes and object properties from an ontology in Protege?

I want to import some classes in Protege from different ontologies to my ontology. For example, I need the classes foaf:Person, org:Site, vcard:Organization, and many more.
I don't want to create them by myself (and modifying their IRI). When I did import the whole ontology (Schema.org, vCard, FOAF, …), I had many elements that I don't need.
Is there any way to do it?
— Have you looked at this thread: protege-project.136.n4.nabble.com/…
— I tried to use it, but it didn't work.
There are subtle moments, especially on step 5.
Open your target ontology.
Open the source ontology in the same window.
Select Refactor > Copy/move/delete axioms:
Select axiom selection method.
Select signature (i. e. a set set of classes, properties etc.) to import. Do not forget to press >> !
Now you can preview axioms to be imported.
Select what you want to do:
8-9. Select your target ontology:
Voila!

get concepts of a loaded ontology using OWL API

I try to get all 'subclass-of' axioms of an ontology. I tried by using the following statement.
System.out.println(MyOntology.getAxioms(AxiomType.SUBCLASS_OF));
Effectively, it returns the ontology 'subclass-of' axioms, except for the first 'subclass-of' axiom which links OWL:Thing with my first ontology class.
I cannot understand why this link isn't taken into account in that case ?
Is there any way to get all 'subclass-of' axioms including those linking OWL:Thing with other classes ?
Here you can find the ontology screenshot and the issue description:

Loading different files using OWL API

I am using OWL API to load different files and merge into one for reasoning. I have one file describing the ontology and several files with individuals. Every individual has foaf properties, e.g., foaf:title, when I print the axioms it shows
'AnnotationAssertion(http://xmlns.com/foaf/0.1/title...'
and reasoning does not work. If I add
<'owl:DatatypeProperty rdf:about="http://xmlns.com/foaf/0.1/title'/>
into the individual file than title loads as
'DataPropertyAssertion(http://xmlns.com/foaf/0.1/title...' and reasoning works.
In the FOAF ontology is says that it is a data property, but loading it did not work either. I am using OWLOntologyMerger to merge the ontologies.
And I cannot add that into every file. Is there a way to do it programmatically or any way?
Thanks.
Use owl:imports from each file to import the base ontology, or foaf.
The problem here is that the owl api needs the declaration to be available either in the file or in the imported ontologies. It is not possible to parse rdf/XML unambiguously otherwise.

owl:imports in Fuseki

I'm new here, and although I've searched for something like this, I couldn't find an answer. So here is my question: How Fuseki handles owl:imports?
Details: I've defined a set of ontologies in different owl files. Let's call two of them of subDomainA.owl and subDomainB.owl.
To "join" these ontologies, I've defined a single owl file that imports the others. Let's call it completeDomain.owl, which owl:imports subDomainA.owl and subDomainB.owl. There are a few statements explicitly declared in completeDomain.owl. If it's not clear, It's something like sweetAll.owl in SWEET.
I need to import these owl files (with RDF/XML syntax) into TDB using Fuseki. How these imports will be handled? I mean, should I load the completeDomain.owl to the default graph and subDomainA.owl and subDomainB.owl to their respective graphs and Fuseki would "understand" imports and let me query all of them at once?
Using tdb:unionDefaultGraph is the same thing? What would happen with the statements declared in completeDomain.owl that uses entities declared in the subDomain ontologies? Also, I couldn't see the difference of tdb:unionDefaultGraph and Union Model.
As you can see, I'm a little bit confused and any help will be appreciated!
Following the tips from Joshua bellow(thanks for them, by the way), here is the answer:
To organize owl:imports into Fuseki, there are 3 options:
1) Import all ontologies files to the default graph.
2) Configure the store using tdb:unionDefaultGraph with true value, and import each file to its own named graph. This way, Fuseki will answer a query to the default graph with the union of all named graphs. Also, each graph can be acessed by its named graph and/or SPARQL GRAPH.
3) A Union Model combines in a single graph other graphs. Any app would not be able to query the graphs separatedely.
The original answer to this question is here!

Resources