Determining the rdf:type of an OWLIndividual

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Determining the rdf:type of an OWLIndividual

kcason

I need to determine the rdf:type of an OWLindividual. For example:

 

boolean mockRoutine(OWLIndividual myIndividual) {

     System.println(“myIndividual: “ + myIndividual.toString());

 

     OWLClass myType = myIndividual.getClassType();   ß something like this?

     System.println(“myType: “ + myType.toString());

 

     return true;

}

 

How do I get the rdf:type of myIndividual?

 

I can set the type of an OWLNamedIndividual like this (see near the end):

 

private OWLNamedIndividual addAxiom(OWLNamedIndividual subject, OWLIndividual object, String predicate, OWLClass type ) {
    System.
out.println("--- addAxiom:");
   
System.out.println("     subject:   " + subject);
   
System.out.println("     object:    " + object.toString());
   
System.out.println("     predicate: " + predicate);
    if
(type != null) {
        System.
out.println("     type:      " + type.toString());
   
} else {
        System.
out.println("     type:      " + "null");
   
}

   
// create the subject
    //OWLNamedIndividual theSubject = myDataFactory.getOWLNamedIndividual(subject, myPrefixManager);
   
OWLNamedIndividual theSubject = subject;
   
// create the object property (predicate)
   
OWLObjectProperty thePredicate = myDataFactory.getOWLObjectProperty(predicate, myPrefixManager);

   
// create the axiom linking the subject/object/predicate all together
   
OWLObjectPropertyAssertionAxiom objectPropertyAssertionAxiom = myDataFactory.getOWLObjectPropertyAssertionAxiom(thePredicate, theSubject, object);

   
// add the axiom to our ontology and save
   
AddAxiom addAxiomChange = new AddAxiom(myOntology, objectPropertyAssertionAxiom);
   
myOntologyManager.applyChange(addAxiomChange);

   
// if the type is known, set it
   
if (type != null) {
        System.
out.println("     ==== Setting the rdf:type...");

       
// create the type axiom
       
OWLClassAssertionAxiom classTypeAssertion = myDataFactory.getOWLClassAssertionAxiom(type, theSubject);

        
// add the axiom to our ontology and save
       
addAxiomChange = new AddAxiom(myOntology, classTypeAssertion);
       
myOntologyManager.applyChange(addAxiomChange);
   
}

   
return theSubject;
}

 

 

Thanks,

 

-Kenny Cason

Radiance Technologies

Cyber Solutions Group

3133 General Hudnell Dr. Ste. 116
San Antonio, TX 78226

[hidden email]

206.550.0049

 


_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
Reply | Threaded
Open this post in threaded view
|

Re: Determining the rdf:type of an OWLIndividual

Lorenz Buehmann

the asserted type(s) or also the inferred type(s)? this is indeed is difference.


Asserted types:

OWLEntitySearcher.getTypes(ind, ont), see [1]


Inferred types:

you have to get the reasoner from Protege first (via getOWLEditorKit(), getOWLModelManager() and so on and so forth)

reasoner.getTypes(ind, false), see [2]





I need to determine the rdf:type of an OWLindividual. For example:

 

boolean mockRoutine(OWLIndividual myIndividual) {

     System.println(“myIndividual: “ + myIndividual.toString());

 

     OWLClass myType = myIndividual.getClassType();   ß something like this?

     System.println(“myType: “ + myType.toString());

 

     return true;

}

 

How do I get the rdf:type of myIndividual?

 

I can set the type of an OWLNamedIndividual like this (see near the end):

 

private OWLNamedIndividual addAxiom(OWLNamedIndividual subject, OWLIndividual object, String predicate, OWLClass type ) {
    System.
out.println("--- addAxiom:");
   
System.out.println("     subject:   " + subject);
   
System.out.println("     object:    " + object.toString());
   
System.out.println("     predicate: " + predicate);
    if
(type != null) {
        System.
out.println("     type:      " + type.toString());
   
} else {
        System.
out.println("     type:      " + "null");
   
}

   
// create the subject
    //OWLNamedIndividual theSubject = myDataFactory.getOWLNamedIndividual(subject, myPrefixManager);
   
OWLNamedIndividual theSubject = subject;
   
// create the object property (predicate)
   
OWLObjectProperty thePredicate = myDataFactory.getOWLObjectProperty(predicate, myPrefixManager);

   
// create the axiom linking the subject/object/predicate all together
   
OWLObjectPropertyAssertionAxiom objectPropertyAssertionAxiom = myDataFactory.getOWLObjectPropertyAssertionAxiom(thePredicate, theSubject, object);

   
// add the axiom to our ontology and save
   
AddAxiom addAxiomChange = new AddAxiom(myOntology, objectPropertyAssertionAxiom);
   
myOntologyManager.applyChange(addAxiomChange);

   
// if the type is known, set it
   
if (type != null) {
        System.
out.println("     ==== Setting the rdf:type...");

       
// create the type axiom
       
OWLClassAssertionAxiom classTypeAssertion = myDataFactory.getOWLClassAssertionAxiom(type, theSubject);

        
// add the axiom to our ontology and save
       
addAxiomChange = new AddAxiom(myOntology, classTypeAssertion);
       
myOntologyManager.applyChange(addAxiomChange);
   
}

   
return theSubject;
}

 

 

Thanks,

 

-Kenny Cason

Radiance Technologies

Cyber Solutions Group

3133 General Hudnell Dr. Ste. 116
San Antonio, TX 78226

[hidden email]

206.550.0049

 


_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center

_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
Reply | Threaded
Open this post in threaded view
|

Re: Determining the rdf:type of an OWLIndividual

kcason

Brilliant, thanks!

 

-Kenny

 

From: protege-dev <[hidden email]> On Behalf Of Lorenz B.
Sent: Thursday, January 31, 2019 1:10 AM
To: [hidden email]
Subject: Re: [protege-dev] Determining the rdf:type of an OWLIndividual

 

 

the asserted type(s) or also the inferred type(s)? this is indeed is difference.

 

Asserted types:

OWLEntitySearcher.getTypes(ind, ont), see [1]

 

Inferred types:

 

you have to get the reasoner from Protege first (via getOWLEditorKit(), getOWLModelManager() and so on and so forth)

 

reasoner.getTypes(ind, false), see [2]

 

 

 

 



I need to determine the rdf:type of an OWLindividual. For example:

 

boolean mockRoutine(OWLIndividual myIndividual) {

     System.println(“myIndividual: “ + myIndividual.toString());

 

     OWLClass myType = myIndividual.getClassType();   ß something like this?

     System.println(“myType: “ + myType.toString());

 

     return true;

}

 

How do I get the rdf:type of myIndividual?

 

I can set the type of an OWLNamedIndividual like this (see near the end):

 

private OWLNamedIndividual addAxiom(OWLNamedIndividual subject, OWLIndividual object, String predicate, OWLClass type ) {
    System.
out.println("--- addAxiom:");
   
System.out.println("     subject:   " + subject);
   
System.out.println("     object:    " + object.toString());
   
System.out.println("     predicate: " + predicate);
    if
(type != null) {
        System.
out.println("     type:      " + type.toString());
   
} else {
        System.
out.println("     type:      " + "null");
   
}

   
// create the subject
    //OWLNamedIndividual theSubject = myDataFactory.getOWLNamedIndividual(subject, myPrefixManager);
   
OWLNamedIndividual theSubject = subject;
   
// create the object property (predicate)
   
OWLObjectProperty thePredicate = myDataFactory.getOWLObjectProperty(predicate, myPrefixManager);

   
// create the axiom linking the subject/object/predicate all together
   
OWLObjectPropertyAssertionAxiom objectPropertyAssertionAxiom = myDataFactory.getOWLObjectPropertyAssertionAxiom(thePredicate, theSubject, object);

   
// add the axiom to our ontology and save
   
AddAxiom addAxiomChange = new AddAxiom(myOntology, objectPropertyAssertionAxiom);
   
myOntologyManager.applyChange(addAxiomChange);

   
// if the type is known, set it
   
if (type != null) {
        System.
out.println("     ==== Setting the rdf:type...");

       
// create the type axiom
       
OWLClassAssertionAxiom classTypeAssertion = myDataFactory.getOWLClassAssertionAxiom(type, theSubject);

        
// add the axiom to our ontology and save
       
addAxiomChange = new AddAxiom(myOntology, classTypeAssertion);
       
myOntologyManager.applyChange(addAxiomChange);
   
}

   
return theSubject;
}

 

 

Thanks,

 

-Kenny Cason

Radiance Technologies

Cyber Solutions Group

3133 General Hudnell Dr. Ste. 116
San Antonio, TX 78226

[hidden email]

206.550.0049

 



_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center

_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev