Search Mailing List Archives


Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[protege-owl] I can read my Ontology but I can't add any resource or property

Matthew Horridge matthew.horridge at stanford.edu
Wed Feb 1 11:40:13 PST 2012


Hi,

Is there a particular reason as to why you need to use the protege-owl api?  If not, can I suggest that you use the OWL API (http://owlapi.sourceforge.net).  This is a more modern API for dealing with OWL.  It also underpins Protege 4 and will eventually underpin Web Protege.

Cheers,

Matthew

On 30 Jan 2012, at 01:10, NoussaB wrote:

> Hello,
> 
> I'm a biginner in protege-owl api and i try to write some example program, i
> am working with eclipse and I am trying to create/retrieve/view resources
> from existing ontology. My problem is that i can't add any thing in my owl
> file but i can read and do test.
> waiting of your response. 
> 
> My code is:
> package onto ;
> import edu.stanford.smi.protegex.owl.ProtegeOWL;
> import
> edu.stanford.smi.protegex.owl.inference.pellet.ProtegePelletOWLAPIReasoner;
> import edu.stanford.smi.protegex.owl.inference.protegeowl.ReasonerManager;
> import edu.stanford.smi.protegex.owl.inference.reasoner.ProtegeReasoner;
> import edu.stanford.smi.protegex.owl.model.*;
> import java.io.FileInputStream; 
> import java.io.InputStream; 
> import java.util.Collection;
> import java.util.Iterator;
> public class Ontology {
> public static void main(String[] args) {
> 
>                   try {
> 	               InputStream inp = new FileInputStream("C:\\Program
> Files\\Protege_3.4.8\\MyOntology.owl"); 
>                   OWLModel owlModel =
> ProtegeOWL.createJenaOWLModelFromInputStream(inp);
>                   OWLNamedClass classeA =
> owlModel.getOWLNamedClass("ClasseA");
>                   if(classeA!= null) {
>                           Collection assertedSubclasses =classeA
> .getNamedSubclasses();
>                           System.out.println("Number of asserted classeA :
> " + assertedSubclasses.size());
>                           ReasonerManager reasonerManager =
> ReasonerManager.getInstance();
>                       	   ProtegeReasoner reasoner =
> reasonerManager.createProtegeReasoner(owlModel,
> ProtegePelletOWLAPIReasoner.class);
>       	                   // Now get the inferred subclasses of classA
>                           Collection inferredSubclasses =
> reasoner.getSubclasses(classeA);
>                           System.out.println("Number of inferred classeA :
> " + inferredSubclasses.size());
>                           for(Iterator it = inferredSubclasses.iterator();
> it.hasNext();) {
>                                   OWLNamedClass curClass = (OWLNamedClass)
> it.next();
>                                   System.out.println("\t" +
> curClass.getName());
>                           }}
>                             	   
>            	      	   
>            	  	OWLNamedClass personClass =
> owlModel.createOWLNamedClass("Person");
> 
>            	    OWLDatatypeProperty ageProperty =
> owlModel.createOWLDatatypeProperty("age");
>            	    ageProperty.setRange(owlModel.getXSDint());
>            	    ageProperty.setDomain(personClass);
> 
>            	    OWLObjectProperty childrenProperty =
> owlModel.createOWLObjectProperty("children");
>            	    childrenProperty.setRange(personClass);
>            	    childrenProperty.setDomain(personClass);
> 
>            	    RDFIndividual darwin =
> personClass.createRDFIndividual("Darwin");
>            	    darwin.setPropertyValue(ageProperty, new Integer(0));
> 
>            	    RDFIndividual holgi =
> personClass.createRDFIndividual("Holger");
>            	    holgi.setPropertyValue(childrenProperty, darwin);
>            	    holgi.setPropertyValue(ageProperty, new Integer(33));
> 	                } catch (Exception e) {
> 	                        e.printStackTrace();
> 	                }
> 	        }
> 	
> 	
> 	       
> 	
> 	
> 	      
> 	
> 	
> 	       
> 	
> 	
> 	       
> 	
> }
> 
> --
> View this message in context: http://protege-ontology-editor-knowledge-acquisition-system.136.n4.nabble.com/I-can-read-my-Ontology-but-I-can-t-add-any-resource-or-property-tp4340437p4340437.html
> Sent from the Protege OWL mailing list archive at Nabble.com.
> _______________________________________________
> protege-owl mailing list
> protege-owl at lists.stanford.edu
> https://mailman.stanford.edu/mailman/listinfo/protege-owl
> 
> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03



More information about the protege-owl mailing list