You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Jos Lehmann <Jo...@bauhaus-luftfahrt.net> on 2018/02/27 10:09:24 UTC

URI of anonymous classes

Hi there 

I am rewriting an ontology using jena. I rewrite each import. When rewriting an importing ontology, anonymous classes (e.g. restrictions or disjointness axioms) of the imported ontology appear twice in the importing ontology, because to re-write the importing ontology I am working with OntModelSpec.OWL_DL_MEM, to make sure rewrite instances asserted in the importing ontology of classes declared in the imported ontology.

Question: is there a way of telling in jena where (at which URI) was a restriction or an axiom asserted?

   Note: Protege has a tooltip saying "Asserted in: URI" of such classes. But the rdf/xml file does not seem to have such a property. 

      Subquestion: Does protege compute this property by looking at all URI of all statements oft he anonymous classes?


Hope I am making sense. Jos

Re: URI of anonymous classes

Posted by ajs6f <aj...@apache.org>.
https://jena.apache.org/documentation/javadoc/jena/org/apache/jena/rdf/model/Statement.html#getModel--

ajs6f

> On Feb 28, 2018, at 2:26 AM, Lorenz Buehmann <bu...@informatik.uni-leipzig.de> wrote:
> 
> Models in Jena contain the statements, thus, you should be able to
> determine which model contains the statement.
> 
> 
> On 27.02.2018 19:59, Jos Lehmann wrote:
>> Hi Lorenz 
>> 
>> If you could be more specific it would help. 
>> 
>> The restrictions I am working with don't seem to have a URI, so I can't tell if, in the input ontologies, they belong to the imported ontology or to the importing ontology. I.e.:
>> 
>> WHEN DOING: 
>> 
>> ExtendedIterator properties = thisClass.listProperties();
>> 		    	  while (properties.hasNext()) {
>> 			        	Statement thisProperty = (Statement) properties.next();
>> 				        if (!(((Character.isDigit(thisProperty.getObject().toString().charAt(0)))) || thisProperty.getObject().toString().startsWith("-"))) {	
>> 				        	newClass.addProperty(thisProperty.getPredicate(), thisProperty.getObject());
>> 				        }
>> 				        else
>> 				        {System.out.println("Anonymous class: " + thisProperty.getObject().toString());		
>> 				        System.out.println("Anonymous class' URI:  "  + ((Resource) thisProperty.getObject()).getURI());
>> 
>> 
>> 
>> I GET, FOR INSTANCE: 
>> 
>> Anonymous class: 1a26f878:161d895229e:-7e84
>> Anonymous class' URI:  null
>> 
>> 
>> How else can I programmatically  determine whether a restriction comes from the imported or from the importing ontology
>> Cheers, Jos
>> 
>> 
>> 
>> -----Ursprüngliche Nachricht-----
>> Von: Lorenz Buehmann [mailto:buehmann@informatik.uni-leipzig.de] 
>> Gesendet: Dienstag, 27. Februar 2018 12:29
>> An: users@jena.apache.org
>> Betreff: Re: AW: URI of anonymous classes
>> 
>> You can get access to imported models via
>> 
>> OntModel::getImportedModel(String uri)
>> 
>> or
>> 
>> OntModel::listSubModels(boolean withImports)
>> 
>> 
>> Javadoc[1] is always your friend.
>> 
>> 
>> [1]
>> https://jena.apache.org/documentation/javadoc/jena/org/apache/jena/ontology/OntModel.html
>> 
>> 
>> On 27.02.2018 11:48, Jos Lehmann wrote:
>>> As an integration to my question (see Ursprüngliche Nachricht) please see further down the ouput of re-writing the importing ontology*. 
>>> The same intersection is repeated. Yet, Protege is able to tell that one of the two intesections comes from the imported ontology the other from the importing ontology. How? How to tell the the same thing in jena.
>>> 
>>> Jos
>>> 
>>> -----Ursprüngliche Nachricht-----
>>> Von: Jos Lehmann 
>>> Gesendet: Dienstag, 27. Februar 2018 11:09
>>> An: users@jena.apache.org
>>> Betreff: URI of anonymous classes
>>> 
>>> Hi there 
>>> 
>>> I am rewriting an ontology using jena. I rewrite each import. When rewriting an importing ontology, anonymous classes (e.g. restrictions or disjointness axioms) of the imported ontology appear twice in the importing ontology, because to re-write the importing ontology I am working with OntModelSpec.OWL_DL_MEM, to make sure rewrite instances asserted in the importing ontology of classes declared in the imported ontology.
>>> 
>>> Question: is there a way of telling in jena where (at which URI) was a restriction or an axiom asserted?
>>> 
>>>   Note: Protege has a tooltip saying "Asserted in: URI" of such classes. But the rdf/xml file does not seem to have such a property. 
>>> 
>>>      Subquestion: Does protege compute this property by looking at all URI of all statements oft he anonymous classes?
>>> 
>>> 
>>> Hope I am making sense. Jos
>>> 
>>> 
>>> 
>>> 
>>> * OUTPUT OF RE-WRITING IMPORTING ONTOLOGY
>>> 
>>> <owl:Class rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#Dimension">
>>>    <rdfs:subClassOf>
>>>      <owl:Class>
>>>        <owl:intersectionOf rdf:parseType="Collection">
>>>          <owl:Restriction>
>>>            <owl:allValuesFrom>
>>>              <owl:Class rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#DimensionFactor"/>
>>>            </owl:allValuesFrom>
>>>            <owl:onProperty>
>>>              <owl:AsymmetricProperty rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#dimensionFactor">
>>>                <rdfs:range>
>>>                  <owl:Class rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#DimensionFactor"/>
>>>                </rdfs:range>
>>>                <dc:source>skos:exactMatch 'factor' [SysML 1.2-QUDV] http://www.omgwiki.org/OMGSysML/doku.php?id=sysml-qudv:quantities_units_dimensions_values_qudv</dc:source>
>>>                <rdfs:comment>Rational number that specifies the factor in the dimension conversion relationship.</rdfs:comment>
>>>                <rdfs:isDefinedBy>http://purl.oclc.org/NET/ssnx/qu</rdfs:isDefinedBy>
>>>                <rdfs:label>dimension factor</rdfs:label>
>>>                <rdfs:seeAlso>http://www.omgsysml.org/qudv#Dimension</rdfs:seeAlso>
>>>                <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/>
>>>              </owl:AsymmetricProperty>
>>>            </owl:onProperty>
>>>          </owl:Restriction>
>>>          <owl:Restriction>
>>>            <owl:onDataRange rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
>>>            <owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
>>>> 1</owl:cardinality>
>>>            <owl:onProperty>
>>>              <owl:DatatypeProperty rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#symbolicExpression"/>
>>>            </owl:onProperty>
>>>          </owl:Restriction>
>>>          <owl:Restriction>
>>>            <owl:onDataRange rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
>>>            <owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
>>>> 1</owl:cardinality>
>>>            <owl:onProperty>
>>>              <owl:DatatypeProperty rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#symbolicExpression"/>
>>>            </owl:onProperty>
>>>          </owl:Restriction>
>>>        </owl:intersectionOf>
>>>      </owl:Class>
>>>    </rdfs:subClassOf>
>>>    <rdfs:subClassOf>
>>>      <owl:Class>
>>>        <owl:intersectionOf rdf:parseType="Collection">
>>>          <owl:Restriction>
>>>            <owl:allValuesFrom>
>>>              <owl:Class rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#DimensionFactor"/>
>>>            </owl:allValuesFrom>
>>>            <owl:onProperty rdf:resource="http://purl.oclc.org/NET/ssnx/qu/qu#dimensionFactor"/>
>>>          </owl:Restriction>
>>>          <owl:Restriction>
>>>            <owl:onDataRange rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
>>>            <owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
>>>> 1</owl:cardinality>
>>>            <owl:onProperty>
>>>              <owl:DatatypeProperty rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#symbolicExpression"/>
>>>            </owl:onProperty>
>>>          </owl:Restriction>
>>>          <owl:Restriction>
>>>            <owl:onDataRange rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
>>>            <owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
>>>> 1</owl:cardinality>
>>>            <owl:onProperty>
>>>              <owl:DatatypeProperty rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#symbolicExpression"/>
>>>            </owl:onProperty>
>>>          </owl:Restriction>
>>>        </owl:intersectionOf>
>>>      </owl:Class>
>>> 
>> 
> 


Re: AW: AW: URI of anonymous classes

Posted by Lorenz Buehmann <bu...@informatik.uni-leipzig.de>.
Models in Jena contain the statements, thus, you should be able to
determine which model contains the statement.


On 27.02.2018 19:59, Jos Lehmann wrote:
> Hi Lorenz 
>
> If you could be more specific it would help. 
>
> The restrictions I am working with don't seem to have a URI, so I can't tell if, in the input ontologies, they belong to the imported ontology or to the importing ontology. I.e.:
>
> WHEN DOING: 
>
> ExtendedIterator properties = thisClass.listProperties();
> 		    	  while (properties.hasNext()) {
> 			        	Statement thisProperty = (Statement) properties.next();
> 				        if (!(((Character.isDigit(thisProperty.getObject().toString().charAt(0)))) || thisProperty.getObject().toString().startsWith("-"))) {	
> 				        	newClass.addProperty(thisProperty.getPredicate(), thisProperty.getObject());
> 				        }
> 				        else
> 				        {System.out.println("Anonymous class: " + thisProperty.getObject().toString());		
> 				        System.out.println("Anonymous class' URI:  "  + ((Resource) thisProperty.getObject()).getURI());
>
>
>
> I GET, FOR INSTANCE: 
>
> Anonymous class: 1a26f878:161d895229e:-7e84
> Anonymous class' URI:  null
>
>
> How else can I programmatically  determine whether a restriction comes from the imported or from the importing ontology
> Cheers, Jos
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: Lorenz Buehmann [mailto:buehmann@informatik.uni-leipzig.de] 
> Gesendet: Dienstag, 27. Februar 2018 12:29
> An: users@jena.apache.org
> Betreff: Re: AW: URI of anonymous classes
>
> You can get access to imported models via
>
> OntModel::getImportedModel(String uri)
>
> or
>
> OntModel::listSubModels(boolean withImports)
>
>
> Javadoc[1] is always your friend.
>
>
> [1]
> https://jena.apache.org/documentation/javadoc/jena/org/apache/jena/ontology/OntModel.html
>
>
> On 27.02.2018 11:48, Jos Lehmann wrote:
>> As an integration to my question (see Ursprüngliche Nachricht) please see further down the ouput of re-writing the importing ontology*. 
>> The same intersection is repeated. Yet, Protege is able to tell that one of the two intesections comes from the imported ontology the other from the importing ontology. How? How to tell the the same thing in jena.
>>
>> Jos
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Jos Lehmann 
>> Gesendet: Dienstag, 27. Februar 2018 11:09
>> An: users@jena.apache.org
>> Betreff: URI of anonymous classes
>>
>> Hi there 
>>
>> I am rewriting an ontology using jena. I rewrite each import. When rewriting an importing ontology, anonymous classes (e.g. restrictions or disjointness axioms) of the imported ontology appear twice in the importing ontology, because to re-write the importing ontology I am working with OntModelSpec.OWL_DL_MEM, to make sure rewrite instances asserted in the importing ontology of classes declared in the imported ontology.
>>
>> Question: is there a way of telling in jena where (at which URI) was a restriction or an axiom asserted?
>>
>>    Note: Protege has a tooltip saying "Asserted in: URI" of such classes. But the rdf/xml file does not seem to have such a property. 
>>
>>       Subquestion: Does protege compute this property by looking at all URI of all statements oft he anonymous classes?
>>
>>
>> Hope I am making sense. Jos
>>
>>
>>
>>
>> * OUTPUT OF RE-WRITING IMPORTING ONTOLOGY
>>
>> <owl:Class rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#Dimension">
>>     <rdfs:subClassOf>
>>       <owl:Class>
>>         <owl:intersectionOf rdf:parseType="Collection">
>>           <owl:Restriction>
>>             <owl:allValuesFrom>
>>               <owl:Class rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#DimensionFactor"/>
>>             </owl:allValuesFrom>
>>             <owl:onProperty>
>>               <owl:AsymmetricProperty rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#dimensionFactor">
>>                 <rdfs:range>
>>                   <owl:Class rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#DimensionFactor"/>
>>                 </rdfs:range>
>>                 <dc:source>skos:exactMatch 'factor' [SysML 1.2-QUDV] http://www.omgwiki.org/OMGSysML/doku.php?id=sysml-qudv:quantities_units_dimensions_values_qudv</dc:source>
>>                 <rdfs:comment>Rational number that specifies the factor in the dimension conversion relationship.</rdfs:comment>
>>                 <rdfs:isDefinedBy>http://purl.oclc.org/NET/ssnx/qu</rdfs:isDefinedBy>
>>                 <rdfs:label>dimension factor</rdfs:label>
>>                 <rdfs:seeAlso>http://www.omgsysml.org/qudv#Dimension</rdfs:seeAlso>
>>                 <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/>
>>               </owl:AsymmetricProperty>
>>             </owl:onProperty>
>>           </owl:Restriction>
>>           <owl:Restriction>
>>             <owl:onDataRange rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
>>             <owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
>>             >1</owl:cardinality>
>>             <owl:onProperty>
>>               <owl:DatatypeProperty rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#symbolicExpression"/>
>>             </owl:onProperty>
>>           </owl:Restriction>
>>           <owl:Restriction>
>>             <owl:onDataRange rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
>>             <owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
>>             >1</owl:cardinality>
>>             <owl:onProperty>
>>               <owl:DatatypeProperty rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#symbolicExpression"/>
>>             </owl:onProperty>
>>           </owl:Restriction>
>>         </owl:intersectionOf>
>>       </owl:Class>
>>     </rdfs:subClassOf>
>>     <rdfs:subClassOf>
>>       <owl:Class>
>>         <owl:intersectionOf rdf:parseType="Collection">
>>           <owl:Restriction>
>>             <owl:allValuesFrom>
>>               <owl:Class rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#DimensionFactor"/>
>>             </owl:allValuesFrom>
>>             <owl:onProperty rdf:resource="http://purl.oclc.org/NET/ssnx/qu/qu#dimensionFactor"/>
>>           </owl:Restriction>
>>           <owl:Restriction>
>>             <owl:onDataRange rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
>>             <owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
>>             >1</owl:cardinality>
>>             <owl:onProperty>
>>               <owl:DatatypeProperty rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#symbolicExpression"/>
>>             </owl:onProperty>
>>           </owl:Restriction>
>>           <owl:Restriction>
>>             <owl:onDataRange rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
>>             <owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
>>             >1</owl:cardinality>
>>             <owl:onProperty>
>>               <owl:DatatypeProperty rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#symbolicExpression"/>
>>             </owl:onProperty>
>>           </owl:Restriction>
>>         </owl:intersectionOf>
>>       </owl:Class>
>>
>


Re: AW: URI of anonymous classes

Posted by Martynas Jusevičius <ma...@atomgraph.com>.
Jos, this reminds me of a similar issue I had:
https://www.mail-archive.com/users@jena.apache.org/msg06279.html

Ideally you should have explicit rdfs:isDefinedBy statements for each term,
linking them to their defining ontology.

On Tue, Feb 27, 2018 at 7:59 PM, Jos Lehmann <
Jos.Lehmann@bauhaus-luftfahrt.net> wrote:

> Hi Lorenz
>
> If you could be more specific it would help.
>
> The restrictions I am working with don't seem to have a URI, so I can't
> tell if, in the input ontologies, they belong to the imported ontology or
> to the importing ontology. I.e.:
>
> WHEN DOING:
>
> ExtendedIterator properties = thisClass.listProperties();
>                           while (properties.hasNext()) {
>                                         Statement thisProperty =
> (Statement) properties.next();
>                                         if (!(((Character.isDigit(
> thisProperty.getObject().toString().charAt(0)))) ||
> thisProperty.getObject().toString().startsWith("-"))) {
>                                                 newClass.addProperty(thisProperty.getPredicate(),
> thisProperty.getObject());
>                                         }
>                                         else
>                                         {System.out.println("Anonymous
> class: " + thisProperty.getObject().toString());
>                                         System.out.println("Anonymous
> class' URI:  "  + ((Resource) thisProperty.getObject()).getURI());
>
>
>
> I GET, FOR INSTANCE:
>
> Anonymous class: 1a26f878:161d895229e:-7e84
> Anonymous class' URI:  null
>
>
> How else can I programmatically  determine whether a restriction comes
> from the imported or from the importing ontology
> Cheers, Jos
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: Lorenz Buehmann [mailto:buehmann@informatik.uni-leipzig.de]
> Gesendet: Dienstag, 27. Februar 2018 12:29
> An: users@jena.apache.org
> Betreff: Re: AW: URI of anonymous classes
>
> You can get access to imported models via
>
> OntModel::getImportedModel(String uri)
>
> or
>
> OntModel::listSubModels(boolean withImports)
>
>
> Javadoc[1] is always your friend.
>
>
> [1]
> https://jena.apache.org/documentation/javadoc/jena/
> org/apache/jena/ontology/OntModel.html
>
>
> On 27.02.2018 11:48, Jos Lehmann wrote:
> > As an integration to my question (see Ursprüngliche Nachricht) please
> see further down the ouput of re-writing the importing ontology*.
> > The same intersection is repeated. Yet, Protege is able to tell that one
> of the two intesections comes from the imported ontology the other from the
> importing ontology. How? How to tell the the same thing in jena.
> >
> > Jos
> >
> > -----Ursprüngliche Nachricht-----
> > Von: Jos Lehmann
> > Gesendet: Dienstag, 27. Februar 2018 11:09
> > An: users@jena.apache.org
> > Betreff: URI of anonymous classes
> >
> > Hi there
> >
> > I am rewriting an ontology using jena. I rewrite each import. When
> rewriting an importing ontology, anonymous classes (e.g. restrictions or
> disjointness axioms) of the imported ontology appear twice in the importing
> ontology, because to re-write the importing ontology I am working with
> OntModelSpec.OWL_DL_MEM, to make sure rewrite instances asserted in the
> importing ontology of classes declared in the imported ontology.
> >
> > Question: is there a way of telling in jena where (at which URI) was a
> restriction or an axiom asserted?
> >
> >    Note: Protege has a tooltip saying "Asserted in: URI" of such
> classes. But the rdf/xml file does not seem to have such a property.
> >
> >       Subquestion: Does protege compute this property by looking at all
> URI of all statements oft he anonymous classes?
> >
> >
> > Hope I am making sense. Jos
> >
> >
> >
> >
> > * OUTPUT OF RE-WRITING IMPORTING ONTOLOGY
> >
> > <owl:Class rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#Dimension">
> >     <rdfs:subClassOf>
> >       <owl:Class>
> >         <owl:intersectionOf rdf:parseType="Collection">
> >           <owl:Restriction>
> >             <owl:allValuesFrom>
> >               <owl:Class rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#
> DimensionFactor"/>
> >             </owl:allValuesFrom>
> >             <owl:onProperty>
> >               <owl:AsymmetricProperty rdf:about="http://purl.oclc.
> org/NET/ssnx/qu/qu#dimensionFactor">
> >                 <rdfs:range>
> >                   <owl:Class rdf:about="http://purl.oclc.
> org/NET/ssnx/qu/qu#DimensionFactor"/>
> >                 </rdfs:range>
> >                 <dc:source>skos:exactMatch 'factor' [SysML 1.2-QUDV]
> http://www.omgwiki.org/OMGSysML/doku.php?id=sysml-qudv:quantities_units_
> dimensions_values_qudv</dc:source>
> >                 <rdfs:comment>Rational number that specifies the factor
> in the dimension conversion relationship.</rdfs:comment>
> >                 <rdfs:isDefinedBy>http://purl.oclc.org/NET/ssnx/qu
> </rdfs:isDefinedBy>
> >                 <rdfs:label>dimension factor</rdfs:label>
> >                 <rdfs:seeAlso>http://www.omgsysml.org/qudv#Dimension</
> rdfs:seeAlso>
> >                 <rdf:type rdf:resource="http://www.w3.
> org/2002/07/owl#ObjectProperty"/>
> >               </owl:AsymmetricProperty>
> >             </owl:onProperty>
> >           </owl:Restriction>
> >           <owl:Restriction>
> >             <owl:onDataRange rdf:resource="http://www.w3.
> org/2001/XMLSchema#string"/>
> >             <owl:cardinality rdf:datatype="http://www.w3.
> org/2001/XMLSchema#int"
> >             >1</owl:cardinality>
> >             <owl:onProperty>
> >               <owl:DatatypeProperty rdf:about="http://purl.oclc.
> org/NET/ssnx/qu/qu#symbolicExpression"/>
> >             </owl:onProperty>
> >           </owl:Restriction>
> >           <owl:Restriction>
> >             <owl:onDataRange rdf:resource="http://www.w3.
> org/2001/XMLSchema#string"/>
> >             <owl:cardinality rdf:datatype="http://www.w3.
> org/2001/XMLSchema#int"
> >             >1</owl:cardinality>
> >             <owl:onProperty>
> >               <owl:DatatypeProperty rdf:about="http://purl.oclc.
> org/NET/ssnx/qu/qu#symbolicExpression"/>
> >             </owl:onProperty>
> >           </owl:Restriction>
> >         </owl:intersectionOf>
> >       </owl:Class>
> >     </rdfs:subClassOf>
> >     <rdfs:subClassOf>
> >       <owl:Class>
> >         <owl:intersectionOf rdf:parseType="Collection">
> >           <owl:Restriction>
> >             <owl:allValuesFrom>
> >               <owl:Class rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#
> DimensionFactor"/>
> >             </owl:allValuesFrom>
> >             <owl:onProperty rdf:resource="http://purl.
> oclc.org/NET/ssnx/qu/qu#dimensionFactor"/>
> >           </owl:Restriction>
> >           <owl:Restriction>
> >             <owl:onDataRange rdf:resource="http://www.w3.
> org/2001/XMLSchema#string"/>
> >             <owl:cardinality rdf:datatype="http://www.w3.
> org/2001/XMLSchema#int"
> >             >1</owl:cardinality>
> >             <owl:onProperty>
> >               <owl:DatatypeProperty rdf:about="http://purl.oclc.
> org/NET/ssnx/qu/qu#symbolicExpression"/>
> >             </owl:onProperty>
> >           </owl:Restriction>
> >           <owl:Restriction>
> >             <owl:onDataRange rdf:resource="http://www.w3.
> org/2001/XMLSchema#string"/>
> >             <owl:cardinality rdf:datatype="http://www.w3.
> org/2001/XMLSchema#int"
> >             >1</owl:cardinality>
> >             <owl:onProperty>
> >               <owl:DatatypeProperty rdf:about="http://purl.oclc.
> org/NET/ssnx/qu/qu#symbolicExpression"/>
> >             </owl:onProperty>
> >           </owl:Restriction>
> >         </owl:intersectionOf>
> >       </owl:Class>
> >
>
>

AW: AW: URI of anonymous classes

Posted by Jos Lehmann <Jo...@bauhaus-luftfahrt.net>.
Hi Lorenz 

If you could be more specific it would help. 

The restrictions I am working with don't seem to have a URI, so I can't tell if, in the input ontologies, they belong to the imported ontology or to the importing ontology. I.e.:

WHEN DOING: 

ExtendedIterator properties = thisClass.listProperties();
		    	  while (properties.hasNext()) {
			        	Statement thisProperty = (Statement) properties.next();
				        if (!(((Character.isDigit(thisProperty.getObject().toString().charAt(0)))) || thisProperty.getObject().toString().startsWith("-"))) {	
				        	newClass.addProperty(thisProperty.getPredicate(), thisProperty.getObject());
				        }
				        else
				        {System.out.println("Anonymous class: " + thisProperty.getObject().toString());		
				        System.out.println("Anonymous class' URI:  "  + ((Resource) thisProperty.getObject()).getURI());



I GET, FOR INSTANCE: 

Anonymous class: 1a26f878:161d895229e:-7e84
Anonymous class' URI:  null


How else can I programmatically  determine whether a restriction comes from the imported or from the importing ontology
Cheers, Jos



-----Ursprüngliche Nachricht-----
Von: Lorenz Buehmann [mailto:buehmann@informatik.uni-leipzig.de] 
Gesendet: Dienstag, 27. Februar 2018 12:29
An: users@jena.apache.org
Betreff: Re: AW: URI of anonymous classes

You can get access to imported models via

OntModel::getImportedModel(String uri)

or

OntModel::listSubModels(boolean withImports)


Javadoc[1] is always your friend.


[1]
https://jena.apache.org/documentation/javadoc/jena/org/apache/jena/ontology/OntModel.html


On 27.02.2018 11:48, Jos Lehmann wrote:
> As an integration to my question (see Ursprüngliche Nachricht) please see further down the ouput of re-writing the importing ontology*. 
> The same intersection is repeated. Yet, Protege is able to tell that one of the two intesections comes from the imported ontology the other from the importing ontology. How? How to tell the the same thing in jena.
>
> Jos
>
> -----Ursprüngliche Nachricht-----
> Von: Jos Lehmann 
> Gesendet: Dienstag, 27. Februar 2018 11:09
> An: users@jena.apache.org
> Betreff: URI of anonymous classes
>
> Hi there 
>
> I am rewriting an ontology using jena. I rewrite each import. When rewriting an importing ontology, anonymous classes (e.g. restrictions or disjointness axioms) of the imported ontology appear twice in the importing ontology, because to re-write the importing ontology I am working with OntModelSpec.OWL_DL_MEM, to make sure rewrite instances asserted in the importing ontology of classes declared in the imported ontology.
>
> Question: is there a way of telling in jena where (at which URI) was a restriction or an axiom asserted?
>
>    Note: Protege has a tooltip saying "Asserted in: URI" of such classes. But the rdf/xml file does not seem to have such a property. 
>
>       Subquestion: Does protege compute this property by looking at all URI of all statements oft he anonymous classes?
>
>
> Hope I am making sense. Jos
>
>
>
>
> * OUTPUT OF RE-WRITING IMPORTING ONTOLOGY
>
> <owl:Class rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#Dimension">
>     <rdfs:subClassOf>
>       <owl:Class>
>         <owl:intersectionOf rdf:parseType="Collection">
>           <owl:Restriction>
>             <owl:allValuesFrom>
>               <owl:Class rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#DimensionFactor"/>
>             </owl:allValuesFrom>
>             <owl:onProperty>
>               <owl:AsymmetricProperty rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#dimensionFactor">
>                 <rdfs:range>
>                   <owl:Class rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#DimensionFactor"/>
>                 </rdfs:range>
>                 <dc:source>skos:exactMatch 'factor' [SysML 1.2-QUDV] http://www.omgwiki.org/OMGSysML/doku.php?id=sysml-qudv:quantities_units_dimensions_values_qudv</dc:source>
>                 <rdfs:comment>Rational number that specifies the factor in the dimension conversion relationship.</rdfs:comment>
>                 <rdfs:isDefinedBy>http://purl.oclc.org/NET/ssnx/qu</rdfs:isDefinedBy>
>                 <rdfs:label>dimension factor</rdfs:label>
>                 <rdfs:seeAlso>http://www.omgsysml.org/qudv#Dimension</rdfs:seeAlso>
>                 <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/>
>               </owl:AsymmetricProperty>
>             </owl:onProperty>
>           </owl:Restriction>
>           <owl:Restriction>
>             <owl:onDataRange rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
>             <owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
>             >1</owl:cardinality>
>             <owl:onProperty>
>               <owl:DatatypeProperty rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#symbolicExpression"/>
>             </owl:onProperty>
>           </owl:Restriction>
>           <owl:Restriction>
>             <owl:onDataRange rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
>             <owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
>             >1</owl:cardinality>
>             <owl:onProperty>
>               <owl:DatatypeProperty rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#symbolicExpression"/>
>             </owl:onProperty>
>           </owl:Restriction>
>         </owl:intersectionOf>
>       </owl:Class>
>     </rdfs:subClassOf>
>     <rdfs:subClassOf>
>       <owl:Class>
>         <owl:intersectionOf rdf:parseType="Collection">
>           <owl:Restriction>
>             <owl:allValuesFrom>
>               <owl:Class rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#DimensionFactor"/>
>             </owl:allValuesFrom>
>             <owl:onProperty rdf:resource="http://purl.oclc.org/NET/ssnx/qu/qu#dimensionFactor"/>
>           </owl:Restriction>
>           <owl:Restriction>
>             <owl:onDataRange rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
>             <owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
>             >1</owl:cardinality>
>             <owl:onProperty>
>               <owl:DatatypeProperty rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#symbolicExpression"/>
>             </owl:onProperty>
>           </owl:Restriction>
>           <owl:Restriction>
>             <owl:onDataRange rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
>             <owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
>             >1</owl:cardinality>
>             <owl:onProperty>
>               <owl:DatatypeProperty rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#symbolicExpression"/>
>             </owl:onProperty>
>           </owl:Restriction>
>         </owl:intersectionOf>
>       </owl:Class>
>


Re: AW: URI of anonymous classes

Posted by Lorenz Buehmann <bu...@informatik.uni-leipzig.de>.
You can get access to imported models via

OntModel::getImportedModel(String uri)

or

OntModel::listSubModels(boolean withImports)


Javadoc[1] is always your friend.


[1]
https://jena.apache.org/documentation/javadoc/jena/org/apache/jena/ontology/OntModel.html


On 27.02.2018 11:48, Jos Lehmann wrote:
> As an integration to my question (see Ursprüngliche Nachricht) please see further down the ouput of re-writing the importing ontology*. 
> The same intersection is repeated. Yet, Protege is able to tell that one of the two intesections comes from the imported ontology the other from the importing ontology. How? How to tell the the same thing in jena.
>
> Jos
>
> -----Ursprüngliche Nachricht-----
> Von: Jos Lehmann 
> Gesendet: Dienstag, 27. Februar 2018 11:09
> An: users@jena.apache.org
> Betreff: URI of anonymous classes
>
> Hi there 
>
> I am rewriting an ontology using jena. I rewrite each import. When rewriting an importing ontology, anonymous classes (e.g. restrictions or disjointness axioms) of the imported ontology appear twice in the importing ontology, because to re-write the importing ontology I am working with OntModelSpec.OWL_DL_MEM, to make sure rewrite instances asserted in the importing ontology of classes declared in the imported ontology.
>
> Question: is there a way of telling in jena where (at which URI) was a restriction or an axiom asserted?
>
>    Note: Protege has a tooltip saying "Asserted in: URI" of such classes. But the rdf/xml file does not seem to have such a property. 
>
>       Subquestion: Does protege compute this property by looking at all URI of all statements oft he anonymous classes?
>
>
> Hope I am making sense. Jos
>
>
>
>
> * OUTPUT OF RE-WRITING IMPORTING ONTOLOGY
>
> <owl:Class rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#Dimension">
>     <rdfs:subClassOf>
>       <owl:Class>
>         <owl:intersectionOf rdf:parseType="Collection">
>           <owl:Restriction>
>             <owl:allValuesFrom>
>               <owl:Class rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#DimensionFactor"/>
>             </owl:allValuesFrom>
>             <owl:onProperty>
>               <owl:AsymmetricProperty rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#dimensionFactor">
>                 <rdfs:range>
>                   <owl:Class rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#DimensionFactor"/>
>                 </rdfs:range>
>                 <dc:source>skos:exactMatch 'factor' [SysML 1.2-QUDV] http://www.omgwiki.org/OMGSysML/doku.php?id=sysml-qudv:quantities_units_dimensions_values_qudv</dc:source>
>                 <rdfs:comment>Rational number that specifies the factor in the dimension conversion relationship.</rdfs:comment>
>                 <rdfs:isDefinedBy>http://purl.oclc.org/NET/ssnx/qu</rdfs:isDefinedBy>
>                 <rdfs:label>dimension factor</rdfs:label>
>                 <rdfs:seeAlso>http://www.omgsysml.org/qudv#Dimension</rdfs:seeAlso>
>                 <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/>
>               </owl:AsymmetricProperty>
>             </owl:onProperty>
>           </owl:Restriction>
>           <owl:Restriction>
>             <owl:onDataRange rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
>             <owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
>             >1</owl:cardinality>
>             <owl:onProperty>
>               <owl:DatatypeProperty rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#symbolicExpression"/>
>             </owl:onProperty>
>           </owl:Restriction>
>           <owl:Restriction>
>             <owl:onDataRange rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
>             <owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
>             >1</owl:cardinality>
>             <owl:onProperty>
>               <owl:DatatypeProperty rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#symbolicExpression"/>
>             </owl:onProperty>
>           </owl:Restriction>
>         </owl:intersectionOf>
>       </owl:Class>
>     </rdfs:subClassOf>
>     <rdfs:subClassOf>
>       <owl:Class>
>         <owl:intersectionOf rdf:parseType="Collection">
>           <owl:Restriction>
>             <owl:allValuesFrom>
>               <owl:Class rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#DimensionFactor"/>
>             </owl:allValuesFrom>
>             <owl:onProperty rdf:resource="http://purl.oclc.org/NET/ssnx/qu/qu#dimensionFactor"/>
>           </owl:Restriction>
>           <owl:Restriction>
>             <owl:onDataRange rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
>             <owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
>             >1</owl:cardinality>
>             <owl:onProperty>
>               <owl:DatatypeProperty rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#symbolicExpression"/>
>             </owl:onProperty>
>           </owl:Restriction>
>           <owl:Restriction>
>             <owl:onDataRange rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
>             <owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
>             >1</owl:cardinality>
>             <owl:onProperty>
>               <owl:DatatypeProperty rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#symbolicExpression"/>
>             </owl:onProperty>
>           </owl:Restriction>
>         </owl:intersectionOf>
>       </owl:Class>
>


AW: URI of anonymous classes

Posted by Jos Lehmann <Jo...@bauhaus-luftfahrt.net>.
As an integration to my question (see Ursprüngliche Nachricht) please see further down the ouput of re-writing the importing ontology*. 
The same intersection is repeated. Yet, Protege is able to tell that one of the two intesections comes from the imported ontology the other from the importing ontology. How? How to tell the the same thing in jena.

Jos

-----Ursprüngliche Nachricht-----
Von: Jos Lehmann 
Gesendet: Dienstag, 27. Februar 2018 11:09
An: users@jena.apache.org
Betreff: URI of anonymous classes

Hi there 

I am rewriting an ontology using jena. I rewrite each import. When rewriting an importing ontology, anonymous classes (e.g. restrictions or disjointness axioms) of the imported ontology appear twice in the importing ontology, because to re-write the importing ontology I am working with OntModelSpec.OWL_DL_MEM, to make sure rewrite instances asserted in the importing ontology of classes declared in the imported ontology.

Question: is there a way of telling in jena where (at which URI) was a restriction or an axiom asserted?

   Note: Protege has a tooltip saying "Asserted in: URI" of such classes. But the rdf/xml file does not seem to have such a property. 

      Subquestion: Does protege compute this property by looking at all URI of all statements oft he anonymous classes?


Hope I am making sense. Jos




* OUTPUT OF RE-WRITING IMPORTING ONTOLOGY

<owl:Class rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#Dimension">
    <rdfs:subClassOf>
      <owl:Class>
        <owl:intersectionOf rdf:parseType="Collection">
          <owl:Restriction>
            <owl:allValuesFrom>
              <owl:Class rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#DimensionFactor"/>
            </owl:allValuesFrom>
            <owl:onProperty>
              <owl:AsymmetricProperty rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#dimensionFactor">
                <rdfs:range>
                  <owl:Class rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#DimensionFactor"/>
                </rdfs:range>
                <dc:source>skos:exactMatch 'factor' [SysML 1.2-QUDV] http://www.omgwiki.org/OMGSysML/doku.php?id=sysml-qudv:quantities_units_dimensions_values_qudv</dc:source>
                <rdfs:comment>Rational number that specifies the factor in the dimension conversion relationship.</rdfs:comment>
                <rdfs:isDefinedBy>http://purl.oclc.org/NET/ssnx/qu</rdfs:isDefinedBy>
                <rdfs:label>dimension factor</rdfs:label>
                <rdfs:seeAlso>http://www.omgsysml.org/qudv#Dimension</rdfs:seeAlso>
                <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/>
              </owl:AsymmetricProperty>
            </owl:onProperty>
          </owl:Restriction>
          <owl:Restriction>
            <owl:onDataRange rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
            <owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
            >1</owl:cardinality>
            <owl:onProperty>
              <owl:DatatypeProperty rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#symbolicExpression"/>
            </owl:onProperty>
          </owl:Restriction>
          <owl:Restriction>
            <owl:onDataRange rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
            <owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
            >1</owl:cardinality>
            <owl:onProperty>
              <owl:DatatypeProperty rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#symbolicExpression"/>
            </owl:onProperty>
          </owl:Restriction>
        </owl:intersectionOf>
      </owl:Class>
    </rdfs:subClassOf>
    <rdfs:subClassOf>
      <owl:Class>
        <owl:intersectionOf rdf:parseType="Collection">
          <owl:Restriction>
            <owl:allValuesFrom>
              <owl:Class rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#DimensionFactor"/>
            </owl:allValuesFrom>
            <owl:onProperty rdf:resource="http://purl.oclc.org/NET/ssnx/qu/qu#dimensionFactor"/>
          </owl:Restriction>
          <owl:Restriction>
            <owl:onDataRange rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
            <owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
            >1</owl:cardinality>
            <owl:onProperty>
              <owl:DatatypeProperty rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#symbolicExpression"/>
            </owl:onProperty>
          </owl:Restriction>
          <owl:Restriction>
            <owl:onDataRange rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
            <owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
            >1</owl:cardinality>
            <owl:onProperty>
              <owl:DatatypeProperty rdf:about="http://purl.oclc.org/NET/ssnx/qu/qu#symbolicExpression"/>
            </owl:onProperty>
          </owl:Restriction>
        </owl:intersectionOf>
      </owl:Class>