@@ -0,0 +1,2259 @@
+import java.io.InputStream;%0A%0Aimport com.hp.hpl.jena.ontology.Individual;%0Aimport com.hp.hpl.jena.ontology.OntClass;%0Aimport com.hp.hpl.jena.ontology.OntModel;%0Aimport com.hp.hpl.jena.ontology.OntModelSpec;%0Aimport com.hp.hpl.jena.ontology.OntResource;%0Aimport com.hp.hpl.jena.rdf.model.ModelFactory;%0Aimport com.hp.hpl.jena.rdf.model.Property;%0Aimport com.hp.hpl.jena.rdf.model.RDFNode;%0Aimport com.hp.hpl.jena.rdf.model.ResIterator;%0Aimport com.hp.hpl.jena.rdf.model.Resource;%0Aimport com.hp.hpl.jena.rdf.model.Statement;%0Aimport com.hp.hpl.jena.rdf.model.StmtIterator;%0Aimport com.hp.hpl.jena.util.FileManager;%0Aimport com.hp.hpl.jena.util.iterator.ExtendedIterator;%0Aimport com.hp.hpl.jena.vocabulary.VCARD;%0A%0A/**%0A * Task 07: Querying ontologies (RDFs)%0A * @author elozano%0A *%0A */%0Apublic class Task07%0A%7B%0A%09public static String ns = %22http://somewhere#%22;%0A%0A%09public static void main(String args%5B%5D)%0A%09%7B%0A%09%09String filename = %22example6.rdf%22;%0A%0A%09%09// Create an empty model%0A%09%09OntModel model = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM);%0A%0A%09%09// Use the FileManager to find the input file%0A%09%09InputStream in = FileManager.get().open(filename);%0A%0A%09%09if (in == null)%0A%09%09%09throw new IllegalArgumentException(%22File: %22+filename+%22 not found%22);%0A%0A%09%09// Read the RDF/XML file%0A%09%09model.read(in, null);%0A%09%09//model.write(System.out,%22Turtle%22);%0A%0A%0A%09%09ExtendedIterator%3C? extends OntResource%3E iterator; %0A%09%09// ** TASK 7.1: List all individuals of %22Person%22 **%0A%09%09OntClass person = model.getOntClass(ns + %22Person%22);%0A%0A%09%09iterator=person.listInstances();%0A%09%09System.out.println(%22Individuals%22);%0A%09%09System.out.println(%22------------------------------------%22);%0A%09%09while(iterator.hasNext())%7B%0A%09%09%09OntResource r = iterator.next();%0A%09%09%09System.out.println(r.getURI());%0A%0A%09%09%7D%0A%09%09System.out.println(%22------------------------------------%22);%0A%09%09// ** TASK 7.2: List all subclasses of %22Person%22 **%0A%09%09iterator=person.listSubClasses();%0A%09%09System.out.println(%22Sublcasses%22);%0A%09%09System.out.println(%22------------------------------------%22);%0A%09%09while(iterator.hasNext())%7B%0A%09%09%09OntResource r = iterator.next();%0A%09%09%09System.out.println(r.getURI());%0A%0A%09%09%7D%0A%09%09System.out.println(%22------------------------------------%22);%0A%09%09// ** TASK 7.3: Make the necessary changes to get as well indirect instances and subclasses. TIP: you need some inference... **%0A%0A%0A%09%7D%0A%7D%0A

Create Task07_Edu.java