1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
import javax.swing.JFileChooser;
import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLClass;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyManager;
static JFileChooser JFileChooser1 = new JFileChooser();
public static void Extractconcepts(){
String jt="";
String uri_onto= null;//la valeur d'IRI de l'ontologie
OWLOntologyManager manager;
OWLOntology ont;
final String tabString = " ";
File fichierCourant = AlignView.JFileChooser1.getSelectedFile();
AlignView.s1="file:///"+fichierCourant.getPath().replace("\\", "/");
//
String uri = AlignView.s1; //L'emplacement de l'ontologie(il se recupère lors de selectionnement de l'ontologie)
System.out.println(uri);
try {
manager = OWLManager.createOWLOntologyManager(); //Crée le manager
ont = manager.loadOntologyFromOntologyDocument(IRI.create(uri));// chargement de l'ontology a partir de l'emplacement "uri"
uri_onto=ont.getOntologyID().getOntologyIRI().toString();//le neoud qui contient le nom de fichier charger
for (OWLClass cls : ont.getClassesInSignature()) {
{
if (cls.getIRI().getFragment()!= null) {
jt=jt+cls.getIRI().getFragment().toString()+"\n";
jTextArea1.append(cls.getIRI().getFragment().toString()+"\n");
jt="";
}}
}
}
catch (Exception e) {
// TODO Auto-generated catch block
} |