Intersection two graphs using Jena

package fr.student.team.example; import java.io.InputStream; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.Statement; import com.hp.hpl.jena.rdf.model.StmtIterator; import com.hp.hpl.jena.util.FileManager; public class Operations { static final String inputFileName = "/Users/student/Documents/workspace/testing_jena/src/testing_jena/file.ttl"; static final String inputFileName2 = "/Users/student/Documents/workspace/testing_jena/src/testing_jena/file2.ttl"; public static void main(String[] args) { // TODO Auto-generated method stub Model model = ModelFactory.createDefaultModel(); InputStream in = FileManager.get().open(inputFileName); Model results = model.read(in, "", "TTL"); Model model2 = ModelFactory.createDefaultModel(); InputStream in2 = FileManager.get().open(inputFileName2); Model results2 = model2.read(in2, "", "TTL"); Model Intersection = results.intersection(results2); Intersection.write(System.out, "TTL"); } } file.ttl @prefix rdf: . @prefix contact: . rdf:type contact:Person; contact:fullName "Eric Miller"; contact:mailbox ; contact:personalTitle "Dr.".
Etiquetas