Protege 3.4.X - Export Current Knowledge Base only in a Jena Model

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

Protege 3.4.X - Export Current Knowledge Base only in a Jena Model

Brice Sommacal
Hello dear community,
 
In my last Protege plugin developement, I have used OntoModel model = ((OWLModel) getKnowledgeBase()).getOntModel(); ) to retrieve the current model of my Protégé Project.
In fact, this piece of code returns all imported models in the Protégé Project.
 
I mean that I have my current Knowledge Base (KB1 in OWL/RDF Database) which imports KB2 (in OWL/RDF Database) and 3 ontologies (O1, O2 and O3 in OWL/RDF file).
I was expecting to get only the triples from KB1 but, in fact, this method return KB1+KB2+O1+O2+O3.
 
> Have you got in mind a way to only retrieve the triples from KB1? 
 
I have made a few try with creator = JenaCreator((OWLModel) getKnowledgeBase(), false, null, null):
   - creator.getOWLFullModel : returns some triples from O2 and the OWL ontology (but not all of these)
   - creator.createOntModel() with few addIgnoreImports(): still the same model
 
My plugin extends AbstractTabWidget.
 
> Do you have any idea to allow me to retrieve only the triples contains in my current project and not the one imported?
 
 
Thanks for your time,
All the best,
 
 
Brice
 

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

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Protege 3.4.X - Export Current Knowledge Base only in a Jena Model

Brice Sommacal
Hello, 

Here is a quick update about my issue.
I have spent the day working on this problem and nothing came up :-(

I have been trying to :
 - setProcessImports to false when creating model with JenaCreator,
 - try reload the exported KB with OntDocumentManager (and setting setProcessImports to false)
 - working only on the Active Ontology:
          DefaultOWLOntology ont = (DefaultOWLOntology) ((OWLModel) getKnowledgeBase()).getDefaultOWLOntology();
          OWLOntology ontOWL = OWLUtil.getActiveOntology(ont.getOWLModel());
          Model activeOntoMode = (Model) ontOWL.getOWLModel().getOntModel();

I have even try to remove submodel using a jena function...

But, it returns:
 - an empty model
 - or the full model (which import everything).

I'm stuck.
Any help would be really appreciated.

BR, 


Brice


2014/1/16 Brice Sommacal <[hidden email]>
Hello dear community,
 
In my last Protege plugin developement, I have used OntoModel model = ((OWLModel) getKnowledgeBase()).getOntModel(); ) to retrieve the current model of my Protégé Project.
In fact, this piece of code returns all imported models in the Protégé Project.
 
I mean that I have my current Knowledge Base (KB1 in OWL/RDF Database) which imports KB2 (in OWL/RDF Database) and 3 ontologies (O1, O2 and O3 in OWL/RDF file).
I was expecting to get only the triples from KB1 but, in fact, this method return KB1+KB2+O1+O2+O3.
 
> Have you got in mind a way to only retrieve the triples from KB1? 
 
I have made a few try with creator = JenaCreator((OWLModel) getKnowledgeBase(), false, null, null):
   - creator.getOWLFullModel : returns some triples from O2 and the OWL ontology (but not all of these)
   - creator.createOntModel() with few addIgnoreImports(): still the same model
 
My plugin extends AbstractTabWidget.
 
> Do you have any idea to allow me to retrieve only the triples contains in my current project and not the one imported?
 
 
Thanks for your time,
All the best,
 
 
Brice
 


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

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Protege 3.4.X - Export Current Knowledge Base only in a Jena Model

Matthew Horridge-2
Administrator
Hi Brice,

I’m not familiar with the Protege 3.x.x code anymore.  However, I was wondering whether you really need to use the Protege 3.x.x APIs for programatically manipulating your ontologies.  Would it not be possible to either use Jena directly or use a higher level API such as the OWL API directly?

Cheers,

Matthew



On 20 Jan 2014, at 08:14, Brice Sommacal <[hidden email]> wrote:

Hello, 

Here is a quick update about my issue.
I have spent the day working on this problem and nothing came up :-(

I have been trying to :
 - setProcessImports to false when creating model with JenaCreator,
 - try reload the exported KB with OntDocumentManager (and setting setProcessImports to false)
 - working only on the Active Ontology:
          DefaultOWLOntology ont = (DefaultOWLOntology) ((OWLModel) getKnowledgeBase()).getDefaultOWLOntology();
          OWLOntology ontOWL = OWLUtil.getActiveOntology(ont.getOWLModel());
          Model activeOntoMode = (Model) ontOWL.getOWLModel().getOntModel();

I have even try to remove submodel using a jena function...

But, it returns:
 - an empty model
 - or the full model (which import everything).

I'm stuck.
Any help would be really appreciated.

BR, 


Brice


2014/1/16 Brice Sommacal <[hidden email]>
Hello dear community,
 
In my last Protege plugin developement, I have used OntoModel model = ((OWLModel) getKnowledgeBase()).getOntModel(); ) to retrieve the current model of my Protégé Project.
In fact, this piece of code returns all imported models in the Protégé Project.
 
I mean that I have my current Knowledge Base (KB1 in OWL/RDF Database) which imports KB2 (in OWL/RDF Database) and 3 ontologies (O1, O2 and O3 in OWL/RDF file).
I was expecting to get only the triples from KB1 but, in fact, this method return KB1+KB2+O1+O2+O3.
 
> Have you got in mind a way to only retrieve the triples from KB1? 
 
I have made a few try with creator = JenaCreator((OWLModel) getKnowledgeBase(), false, null, null):
   - creator.getOWLFullModel : returns some triples from O2 and the OWL ontology (but not all of these)
   - creator.createOntModel() with few addIgnoreImports(): still the same model
 
My plugin extends AbstractTabWidget.
 
> Do you have any idea to allow me to retrieve only the triples contains in my current project and not the one imported?
 
 
Thanks for your time,
All the best,
 
 
Brice
 

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

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


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

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Protege 3.4.X - Export Current Knowledge Base only in a Jena Model

Brice Sommacal
Hello Matthew, 

Thanks for your reply. My wish is to use high level API like Jena.
But, before using Jena, I need to get the Model (or OntModel) that we are building through Protégé.

In order to do that, I use KnowledgeBase kb = ((OWLModel) getKnowledgeBase());
and OntModel model = ((OWLModel) kb).getOntModel();

The problem is that "model" is not what I was expecting. We retrieve in model all the imported ontologies. (and I want only the one in the upper level).

For example, I made the following tests:

Test 1: 
Resource res = model.getResource("FULL_URI_of_IMPORTED_RESSOURCE");
System.out.println("isInBaseMOdel: " + model.isInBaseModel(res));
=> It returns true. 

Test 2:
List<OntModel> importModels = new ArrayList<OntModel>();
    for (Iterator<OntModel> j = model.listSubModels(); j.hasNext();)
    {
      OntModel temp = (OntModel) j.next();
      importModels.add(temp);
      System.out.println(" " + temp.size() + " " + temp.getBaseModel());
}
=> It returns 3 subModels (what I was expecting :-)) ; but their sizes are equal to 0. 

So far, I wanted to make one more test by configuring the DocumentManager used by getKnwoledgeBase().
Something like:  ((OWLModel) kb).getOntModel().getDocumentManager().setProcessImports(false);
=> But it fails and still return all imported models. 

With best regards, 


Brice


2014/1/21 Matthew Horridge <[hidden email]>
Hi Brice,

I’m not familiar with the Protege 3.x.x code anymore.  However, I was wondering whether you really need to use the Protege 3.x.x APIs for programatically manipulating your ontologies.  Would it not be possible to either use Jena directly or use a higher level API such as the OWL API directly?

Cheers,

Matthew



On 20 Jan 2014, at 08:14, Brice Sommacal <[hidden email]> wrote:

Hello, 

Here is a quick update about my issue.
I have spent the day working on this problem and nothing came up :-(

I have been trying to :
 - setProcessImports to false when creating model with JenaCreator,
 - try reload the exported KB with OntDocumentManager (and setting setProcessImports to false)
 - working only on the Active Ontology:
          DefaultOWLOntology ont = (DefaultOWLOntology) ((OWLModel) getKnowledgeBase()).getDefaultOWLOntology();
          OWLOntology ontOWL = OWLUtil.getActiveOntology(ont.getOWLModel());
          Model activeOntoMode = (Model) ontOWL.getOWLModel().getOntModel();

I have even try to remove submodel using a jena function...

But, it returns:
 - an empty model
 - or the full model (which import everything).

I'm stuck.
Any help would be really appreciated.

BR, 


Brice


2014/1/16 Brice Sommacal <[hidden email]>
Hello dear community,
 
In my last Protege plugin developement, I have used OntoModel model = ((OWLModel) getKnowledgeBase()).getOntModel(); ) to retrieve the current model of my Protégé Project.
In fact, this piece of code returns all imported models in the Protégé Project.
 
I mean that I have my current Knowledge Base (KB1 in OWL/RDF Database) which imports KB2 (in OWL/RDF Database) and 3 ontologies (O1, O2 and O3 in OWL/RDF file).
I was expecting to get only the triples from KB1 but, in fact, this method return KB1+KB2+O1+O2+O3.
 
> Have you got in mind a way to only retrieve the triples from KB1? 
 
I have made a few try with creator = JenaCreator((OWLModel) getKnowledgeBase(), false, null, null):
   - creator.getOWLFullModel : returns some triples from O2 and the OWL ontology (but not all of these)
   - creator.createOntModel() with few addIgnoreImports(): still the same model
 
My plugin extends AbstractTabWidget.
 
> Do you have any idea to allow me to retrieve only the triples contains in my current project and not the one imported?
 
 
Thanks for your time,
All the best,
 
 
Brice
 

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

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


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

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03



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

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03