Discussion:
How to create (or copy) annotations of annotations (i.e. axioms) (from a model) to a(nother) model in jena?
Jos Lehmann
2016-12-08 16:32:18 UTC
Permalink
Hi there

SITUATION

1. I have an ontology with individuals that have (i) Annotations as well as (ii) Annotations of Annotations.

2. In RDF/XML, (ii) above are expressed as Axioms as in Example#1 below.

3. I manage to extract (ii) from the my RDF ontology using Code#1 below and I get Output#1

PROBLEM

4. I have managed to copy the individuals and their annotations ((i) above) but fail to copy the annotations of annotations ((ii)) to the second model. I have unsuccessfully tried by adding to Code#1 (see upper-case comment) something like:

model2.createResource(thisPropertyOfThisInstanceProperty);



Please let me know if you need more info or you can think of doing this.

Thank you in advance for the advice.
Jos Lehmann

Knowledge Management
Bauhaus Luftfahrt e.V.
GERMANY




Example#1 (RDF/XML Input)

<owl:Axiom>
<owl:annotatedSource rdf:resource="http://www.XXX.net/ontologies/2016/Ls_Ontology.owl#ATR"/>
<owl:annotatedProperty rdf:resource="http://www. XXX.net/ontologies/2016/PS_Ontology.owl#Alias_English_Alias_9"/>
<owl:annotatedTarget xml:lang="en">Whyatr.com</owl:annotatedTarget>
<ps:Disambiguation_English_Word_1 xml:lang="en">airplane</ps:Disambiguation_English_Word_1>
<ps:Disambiguation_English_Word_2 xml:lang="en">airframer</ps:Disambiguation_English_Word_2>
</owl:Axiom>

END-- Example#1



Code#1 (adapted from https://www.google.de/#q=jena+how+to+create+an+axiom+from+a+model+to+another+an+axiom)

ExtendedIterator propertiesOfThisInstanceProperty = model.listSubjectsWithProperty(RDF.type, OWL2.Axiom);
//
while (propertiesOfThisInstanceProperty.hasNext()) {

Resource thisPropertyOfThisInstanceProperty = (Resource) propertiesOfThisInstanceProperty.next();
System.out.println("Found axiom: " + thisPropertyOfThisInstanceProperty.toString());
ExtendedIterator test = thisPropertyOfThisInstanceProperty.listProperties();
// FAILED ADDITION OF CODE IN 4. ABOVE
while (test.hasNext()) {
//
Statement thisPropertyOfNewInstanceProperty = (Statement) test.next();
System.out.println(" Found axiom-related stuff: " + thisPropertyOfNewInstanceProperty.toString());

}


}
END-- Code#1



Output#1

Found axiom: -f670fe7:158df287be1:-7fe4
Found axiom-related stuff: [-f670fe7:158df287be1:-7fe4, http://www. XXX.net/ontologies/2016/PS_Ontology.owl#Disambiguation_English_Word_2, "airframer"@en]
Found axiom-related stuff: [-f670fe7:158df287be1:-7fe4, http://www. XXX.net/ontologies/2016/PS_Ontology.owl#Disambiguation_English_Word_1, "airplane"@en]
Found axiom-related stuff: [-f670fe7:158df287be1:-7fe4, http://www.w3.org/2002/07/owl#annotatedTarget, "Whyatr.com"@en]
Found axiom-related stuff: [-f670fe7:158df287be1:-7fe4, http://www.w3.org/2002/07/owl#annotatedProperty, http://www XXX.net/ontologies/2016/PS_Ontology.owl#Alias_English_Alias_9]
Found axiom-related stuff: [-f670fe7:158df287be1:-7fe4, http://www.w3.org/2002/07/owl#annotatedSource, http://www. XXX.net/ontologies/2016/Ls_Ontology.owl#ATR]
Found axiom-related stuff: [-f670fe7:158df287be1:-7fe4, http://www.w3.org/1999/02/22-rdf-syntax-ns#type, http://www.w3.org/2002/07/owl#Axiom]

END-- Output#1
Jos Lehmann
2016-12-09 08:50:55 UTC
Permalink
Hi there



SITUATION

1. I have an ontology with individuals that have (i) Annotations as well as (ii) Annotations of Annotations.



2. In RDF/XML, (ii) above are expressed as Axioms as in Example#1 below.



3. I manage to extract (ii) from the my RDF ontology using Code#1 below and I get Output#1



PROBLEM



4. I have managed to copy the individuals and their annotations ((i) above) but fail to copy the annotations of annotations ((ii)) to the second model. I have unsuccessfully tried by adding to Code#1 (see upper-case comment) something like:



model2.createResource(thisPropertyOfThisInstanceProperty);







Please let me know if you need more info or you can think of doing this.



Thank you in advance for the advice.

Jos Lehmann



Knowledge Management

Bauhaus Luftfahrt e.V.

GERMANY









Example#1 (RDF/XML Input)



<owl:Axiom>

<owl:annotatedSource rdf:resource="http://www.XXX.net/ontologies/2016/Ls_Ontology.owl#ATR"/>

<owl:annotatedProperty rdf:resource="http://www. XXX.net/ontologies/2016/PS_Ontology.owl#Alias_English_Alias_9<http://www.%20XXX.net/ontologies/2016/PS_Ontology.owl#Alias_English_Alias_9>"/>

<owl:annotatedTarget xml:lang="en">Whyatr.com</owl:annotatedTarget>

<ps:Disambiguation_English_Word_1 xml:lang="en">airplane</ps:Disambiguation_English_Word_1>

<ps:Disambiguation_English_Word_2 xml:lang="en">airframer</ps:Disambiguation_English_Word_2>

</owl:Axiom>



END-- Example#1







Code#1 (adapted from https://www.google.de/#q=jena+how+to+create+an+axiom+from+a+model+to+another+an+axiom)



ExtendedIterator propertiesOfThisInstanceProperty = model.listSubjectsWithProperty(RDF.type, OWL2.Axiom);

//

while (propertiesOfThisInstanceProperty.hasNext()) {



Resource thisPropertyOfThisInstanceProperty = (Resource) propertiesOfThisInstanceProperty.next();

System.out.println("Found axiom: " + thisPropertyOfThisInstanceProperty.toString());

ExtendedIterator test = thisPropertyOfThisInstanceProperty.listProperties();

// FAILED ADDITION OF CODE IN 4. ABOVE

while (test.hasNext()) {

//

Statement thisPropertyOfNewInstanceProperty = (Statement) test.next();

System.out.println(" Found axiom-related stuff: " + thisPropertyOfNewInstanceProperty.toString());



}





}

END-- Code#1







Output#1



Found axiom: -f670fe7:158df287be1:-7fe4

Found axiom-related stuff: [-f670fe7:158df287be1:-7fe4, http://www. XXX.net/ontologies/2016/PS_Ontology.owl#Disambiguation_English_Word_2, "airframer"@en]

Found axiom-related stuff: [-f670fe7:158df287be1:-7fe4, http://www. XXX.net/ontologies/2016/PS_Ontology.owl#Disambiguation_English_Word_1, "airplane"@en]

Found axiom-related stuff: [-f670fe7:158df287be1:-7fe4, http://www.w3.org/2002/07/owl#annotatedTarget, "Whyatr.com"@en<mailto:%22Whyatr.com%***@en>]

Found axiom-related stuff: [-f670fe7:158df287be1:-7fe4, http://www.w3.org/2002/07/owl#annotatedProperty, http://www XXX.net/ontologies/2016/PS_Ontology.owl#Alias_English_Alias_9]

Found axiom-related stuff: [-f670fe7:158df287be1:-7fe4, http://www.w3.org/2002/07/owl#annotatedSource, http://www. XXX.net/ontologies/2016/Ls_Ontology.owl#ATR]

Found axiom-related stuff: [-f670fe7:158df287be1:-7fe4, http://www.w3.org/1999/02/22-rdf-syntax-ns#type, http://www.w3.org/2002/07/owl#Axiom]



END-- Output#1
Dave Reynolds
2016-12-09 09:05:54 UTC
Permalink
You sent this message yesterday, bear in mind that the list is run by
volunteers.

It is not clear exactly what you've tried and what doesn't work.

To copy resources from one model to another you use model#add, which can
take a single Statement, an array/List of Statements or a StmtIterator.
So you should be able adapt your code which lists the Statements that
make up the Axioms you are interested in and call add on the new model.
Probably just:

ResIterator propertiesOfThisInstanceProperty = model
.listSubjectsWithProperty(RDF.type, OWL2.Axiom);
while (propertiesOfThisInstanceProperty.hasNext()) {
Resource thisPropertyOfThisInstanceProperty = (Resource)
propertiesOfThisInstanceProperty.next();
model2.add( thisPropertyOfThisInstanceProperty.listProperties() );
}

Dave
Post by Jos Lehmann
Hi there
SITUATION
1. I have an ontology with individuals that have (i) Annotations as well as (ii) Annotations of Annotations.
2. In RDF/XML, (ii) above are expressed as Axioms as in Example#1 below.
3. I manage to extract (ii) from the my RDF ontology using Code#1 below and I get Output#1
PROBLEM
model2.createResource(thisPropertyOfThisInstanceProperty);
Please let me know if you need more info or you can think of doing this.
Thank you in advance for the advice.
Jos Lehmann
Knowledge Management
Bauhaus Luftfahrt e.V.
GERMANY
Example#1 (RDF/XML Input)
<owl:Axiom>
<owl:annotatedSource rdf:resource="http://www.XXX.net/ontologies/2016/Ls_Ontology.owl#ATR"/>
<owl:annotatedProperty rdf:resource="http://www. XXX.net/ontologies/2016/PS_Ontology.owl#Alias_English_Alias_9<http://www.%20XXX.net/ontologies/2016/PS_Ontology.owl#Alias_English_Alias_9>"/>
<owl:annotatedTarget xml:lang="en">Whyatr.com</owl:annotatedTarget>
<ps:Disambiguation_English_Word_1 xml:lang="en">airplane</ps:Disambiguation_English_Word_1>
<ps:Disambiguation_English_Word_2 xml:lang="en">airframer</ps:Disambiguation_English_Word_2>
</owl:Axiom>
END-- Example#1
Code#1 (adapted from https://www.google.de/#q=jena+how+to+create+an+axiom+from+a+model+to+another+an+axiom)
ExtendedIterator propertiesOfThisInstanceProperty = model.listSubjectsWithProperty(RDF.type, OWL2.Axiom);
//
while (propertiesOfThisInstanceProperty.hasNext()) {
Resource thisPropertyOfThisInstanceProperty = (Resource) propertiesOfThisInstanceProperty.next();
System.out.println("Found axiom: " + thisPropertyOfThisInstanceProperty.toString());
ExtendedIterator test = thisPropertyOfThisInstanceProperty.listProperties();
// FAILED ADDITION OF CODE IN 4. ABOVE
while (test.hasNext()) {
//
Statement thisPropertyOfNewInstanceProperty = (Statement) test.next();
System.out.println(" Found axiom-related stuff: " + thisPropertyOfNewInstanceProperty.toString());
}
}
END-- Code#1
Output#1
Found axiom: -f670fe7:158df287be1:-7fe4
Found axiom-related stuff: [-f670fe7:158df287be1:-7fe4, http://www.w3.org/2002/07/owl#annotatedProperty, http://www XXX.net/ontologies/2016/PS_Ontology.owl#Alias_English_Alias_9]
Found axiom-related stuff: [-f670fe7:158df287be1:-7fe4, http://www.w3.org/2002/07/owl#annotatedSource, http://www. XXX.net/ontologies/2016/Ls_Ontology.owl#ATR]
Found axiom-related stuff: [-f670fe7:158df287be1:-7fe4, http://www.w3.org/1999/02/22-rdf-syntax-ns#type, http://www.w3.org/2002/07/owl#Axiom]
END-- Output#1
Loading...