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 51 52 53 54 55 56 57 58 59 60 61 62 63
| package recherche;
import com.hp.hpl.jena.ontology.Individual;
import com.hp.hpl.jena.ontology.OntClass;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.ontology.OntModelSpec;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.util.FileManager;
import java.util.Arrays;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Scanner;
public class Recherche{
private static String []z= new String [170];
public static void main (String[] args){
String x;
int p = 0;
boolean r =false;
String owlFile = "C:/ProjetMI/MI.owl";
// Creation d'un modele d'ontologie pour une ontologie OWL-DL avec un resonneur RDFS
OntModel m = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM_RDFS_INF);
FileManager.get().readModel( m, owlFile );
//Récupérer la liste des individus
Iterator<Individual> Instance = m.listIndividuals();
//Insertion dans le tableau
for ( ; Instance.hasNext() ; ){
Individual ins = Instance.next();
z[p] = ins.getLocalName();
p++;
}
System.out.println(Arrays.toString(z));
for (p=0;p<z.length;p++){
System.out.println(z[p]);
}
System.out.println("entrez quelque chose");
Scanner S= new Scanner (System.in);
x = S.nextLine();
for (p=0;p<z.length;p++) {
if (x == z[p]) { r=true; }
else { r=false; }
}
if ( r==true )
{ System.out.println(x+ "cet individu est existant"); }
else
{ System.out.println("erreur"); }
}
} |
Partager