當前位置: 首頁>>代碼示例>>Java>>正文


Java OntModel.getIndividual方法代碼示例

本文整理匯總了Java中com.hp.hpl.jena.ontology.OntModel.getIndividual方法的典型用法代碼示例。如果您正苦於以下問題:Java OntModel.getIndividual方法的具體用法?Java OntModel.getIndividual怎麽用?Java OntModel.getIndividual使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.hp.hpl.jena.ontology.OntModel的用法示例。


在下文中一共展示了OntModel.getIndividual方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getUriInModel

import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
private static synchronized String getUriInModel(OntModel model, String ns, String name) {
	Resource r = model.getAnnotationProperty(ns + name);
       if (r != null) {
           return r.getURI();
       }
       r = model.getDatatypeProperty(ns + name);
       if (r != null) {
           return r.getURI();
       }
       r = model.getObjectProperty(ns + name);
       if (r != null) {
           return r.getURI();
       }
       r = model.getOntClass(ns + name);
       if (r != null) {
           return r.getURI();
       }
       r = model.getIndividual(ns + name);
       if (r != null) {
           return r.getURI();
       }
       if (RDF.type.getURI().equals(ns + name)) {
       	return RDF.type.getURI();
       }
       return null;
}
 
開發者ID:crapo,項目名稱:sadlos2,代碼行數:27,代碼來源:JenaTranslatorPlugin.java

示例2: isOfKind

import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
static boolean isOfKind(Resource rrule, String uri) {
    if (rrule == null || uri == null || uri.isEmpty() || rrule.getURI() == null) {
        return false;
    }
    OntModel ontModel = ModelFactory.createOntologyModel();
    ontModel.add(coreModel);
    Individual res = ontModel.getIndividual(rrule.getURI());
    OntClass clase = ontModel.getOntClass(uri);
    if (res == null || clase == null) {
        return false;
    }
    return res.hasOntClass(clase);

}
 
開發者ID:oeg-upm,項目名稱:odrlapi,代碼行數:15,代碼來源:RDFUtils.java

示例3: main

import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
public static void main(String args[])
{
	String filename = "src/rdf examples/example5.rdf";
	
	// Create an empty model
	OntModel model = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM);
	
	// Use the FileManager to find the input file
	InputStream in = FileManager.get().open(filename);

	if (in == null)
		throw new IllegalArgumentException("File: "+filename+" not found");

	// Read the RDF/XML file
	model.read(in, null);
	
	// Create a new class named "Researcher"
	OntClass researcher = model.createClass(ns+"Researcher");
	
	// ** TASK 6.1: Create a new class named "University" **
	OntClass university = model.createClass(ns+"University");
	
	
	// ** TASK 6.2: Add "Researcher" as a subclass of "Person" **
	model.getOntClass(ns+"Person").addSubClass(researcher);
	
	// ** TASK 6.3: Create a new property named "worksIn" **
	Property worksIn = model.createProperty(ns+"WorksIn");
	
	// ** TASK 6.4: Create a new individual of Researcher named "Jane Smith" **
	Individual inJane = researcher.createIndividual(ns+"JaneSmith");
	model.createIndividual(inJane);
	
	// ** TASK 6.5: Add to the individual JaneSmith the fullName, given and family names **
	inJane.addLiteral(VCARD.FN, "Jane Smith");
	inJane.addLiteral(VCARD.Given, "Jane");
	inJane.addLiteral(VCARD.Family, "Smith");
	
	// ** TASK 6.6: Add UPM as the university where John Smith works **
	Individual UPM = university.createIndividual(ns+"UPM");
	Individual john = model.getIndividual(ns+"JohnSmith");
	john.addProperty(worksIn, UPM);
	
	
	model.write(System.out, "RDF/XML-ABBREV");
}
 
開發者ID:FacultadInformatica-LinkedData,項目名稱:Curso2014-2015,代碼行數:47,代碼來源:jchanam_Task06.java

示例4: main

import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
public static void main(String args[])
{
	String filename = "src/pruebasJena/examplesRDF/example5.rdf";
	
	// Create an empty model
	OntModel model = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM);
	
	// Use the FileManager to find the input file
	InputStream in = FileManager.get().open(filename);

	if (in == null)
		throw new IllegalArgumentException("File: "+filename+" not found");

	// Read the RDF/XML file
	model.read(in, null);
	
	// Create a new class named "Researcher"
	OntClass researcher = model.createClass(ns+"Researcher");
	
	// ** TASK 6.1: Create a new class named "University" **
	OntClass university = model.createClass(ns+"University");
	
	// ** TASK 6.2: Add "Researcher" as a subclass of "Person" **
	model.getOntClass(ns+"Person").addSubClass(researcher);
	
	// ** TASK 6.3: Create a new property named "worksIn" **
	Property worksIn = model.createProperty(ns+"worksIn");
	
	// ** TASK 6.4: Create a new individual of Researcher named "Jane Smith" **
	Individual janeSmith = researcher.createIndividual(ns+"JaneSmith");
	
	// ** TASK 6.5: Add to the individual JaneSmith the fullName, given and family names **
	janeSmith.addProperty(VCARD.FN, "JaneSmith");
	janeSmith.addProperty(VCARD.Given, "Jane");
	janeSmith.addProperty(VCARD.Family, "Smith");
	
	// ** TASK 6.6: Add UPM as the university where John Smith works **
	Individual johnSmith = model.getIndividual(ns+"JohnSmith");
	Individual upm = university.createIndividual(ns+"UPM");

	johnSmith.addProperty(worksIn, upm);
	
	model.write(System.out, "RDF/XML-ABBREV");
}
 
開發者ID:FacultadInformatica-LinkedData,項目名稱:Curso2014-2015,代碼行數:45,代碼來源:Task06JorgeFernandezManteca.java

示例5: main

import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
public static void main(String args[])
{
	String filename = "example5.rdf";
	
	// Create an empty model
	OntModel model = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM);
	
	// Use the FileManager to find the input file
	InputStream in = FileManager.get().open(filename);

	if (in == null)
		throw new IllegalArgumentException("File: "+filename+" not found");

	// Read the RDF/XML file
	model.read(in, null);
	
	// Create a new class named "Researcher"
	OntClass researcher = model.createClass(ns+"Researcher");
	
	// ** TASK 6.1: Create a new class named "University" **
	OntClass university = model.createClass(ns + "University");
	
	
	// ** TASK 6.2: Add "Researcher" as a subclass of "Person" **
	OntClass person = model.getOntClass(ns + "Person");
	person.addSubClass(researcher);
	
	
	// ** TASK 6.3: Create a new property named "worksIn" **
	Property worksIn = model.createProperty(ns + "worksIn");
	
	// ** TASK 6.4: Create a new individual of Researcher named "Jane Smith" **
	Individual janeSmith = researcher.createIndividual(ns + "JaneSmith");
	
	// ** TASK 6.5: Add to the individual JaneSmith the fullName, given and family names **
	janeSmith.addLiteral(VCARD.FN, "Jane Smith");
	janeSmith.addLiteral(VCARD.Given, "Jane");
	janeSmith.addLiteral(VCARD.Family, "Smith");
	
	// ** TASK 6.6: Add UPM as the university where John Smith works **		
	Individual johnSmith = model.getIndividual(ns + "JohnSmith");
	Individual upm = university.createIndividual(ns + "UPM");

	
	johnSmith.addProperty(worksIn, upm);
	
	model.write(System.out, "RDF/XML-ABBREV");
	System.out.println();
	System.out.println("---------------------------------------");
	System.out.println();
	model.write(System.out, "Turtle");
}
 
開發者ID:FacultadInformatica-LinkedData,項目名稱:Curso2014-2015,代碼行數:53,代碼來源:Task06_Gueton.java

示例6: main

import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
public static void main(String args[])
{
	String filename = "rdf examples/example5.rdf";
	
	// Create an empty model
	OntModel model = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM);
	
	// Use the FileManager to find the input file
	InputStream in = FileManager.get().open(filename);

	if (in == null)
		throw new IllegalArgumentException("File: "+filename+" not found");

	// Read the RDF/XML file
	model.read(in, null);
	
	// Create a new class named "Researcher"
	OntClass researcher = model.createClass(ns+"Researcher");
	
	// ** TASK 6.1: Create a new class named "University" **
	OntClass university = model.createClass(ns+"University");
	
	// ** TASK 6.2: Add "Researcher" as a subclass of "Person" **
	OntClass person = model.getOntClass(ns+"Person");
	person.addSubClass(researcher);
	
	// ** TASK 6.3: Create a new property named "worksIn" **
	Property worksIn = model.createProperty(ns+"worksIn");		
	
	// ** TASK 6.4: Create a new individual of Researcher named "Jane Smith" **
	Individual janeSmith = researcher.createIndividual(ns+"JaneSmith");
	
	// ** TASK 6.5: Add to the individual JaneSmith the fullName, given and family names **
	janeSmith.addLiteral(VCARD.FN,"Jane Smith");
	janeSmith.addLiteral(VCARD.Given,"Jane");
	janeSmith.addLiteral(VCARD.Family,"Smith");
	
	// ** TASK 6.6: Add UPM as the university where John Smith works **
	Individual johnSmith = model.getIndividual(ns+"JohnSmith");
	Individual upm = university.createIndividual(ns+"UPM");

	johnSmith.addProperty(worksIn, upm);
	
	model.write(System.out, "RDF/XML-ABBREV");
}
 
開發者ID:FacultadInformatica-LinkedData,項目名稱:Curso2014-2015,代碼行數:46,代碼來源:Task06_Oscarf.java

示例7: main

import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
public static void main(String args[])
{
	String filename = "example5.rdf";
	
	// Create an empty model
	OntModel model = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM);
	
	// Use the FileManager to find the input file
	InputStream in = FileManager.get().open(filename);

	if (in == null)
		throw new IllegalArgumentException("File: "+filename+" not found");

	// Read the RDF/XML file
	model.read(in, null);
	
	// Create a new class named "Researcher"
	OntClass researcher = model.createClass(ns+"Researcher");
	
	// ** TASK 6.1: Create a new class named "University" **
	OntClass university = model.createClass(ns+"University");
	
	// ** TASK 6.2: Add "Researcher" as a subclass of "Person" **
	OntClass person = model.getOntClass(ns+"Person");
	person.addSubClass(researcher);
	
	// ** TASK 6.3: Create a new property named "worksIn" **
	Property propiedad = model.createProperty(ns+"worksIn");
	
	// ** TASK 6.4: Create a new individual of Researcher named "Jane Smith" **
	Individual janeSmith = researcher.createIndividual(ns+"JaneSmith");
	
	// ** TASK 6.5: Add to the individual JaneSmith the fullName, given and family names **
	janeSmith.addProperty(VCARD.FN, "JaneSmith");
	janeSmith.addProperty(VCARD.Given, "Jane");
	janeSmith.addProperty(VCARD.Family, "Smith");
	
	// ** TASK 6.6: Add UPM as the university where John Smith works **
	Individual upm = university.createIndividual(ns+"UPM");
	Individual johnSmith = model.getIndividual(ns + "JohnSmith");
	johnSmith.addProperty(propiedad, upm);
	
	//model.write(System.out, "RDF/XML-ABBREV");
	model.write(System.out, "TURTLE");
}
 
開發者ID:FacultadInformatica-LinkedData,項目名稱:Curso2014-2015,代碼行數:46,代碼來源:Task06_AngelicaGuaman.java

示例8: main

import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
public static void main(String args[])
{
	String filename = "example5.rdf";
	
	// Create an empty model
	OntModel model = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM);
	
	// Use the FileManager to find the input file
	InputStream in = FileManager.get().open(filename);

	if (in == null)
		throw new IllegalArgumentException("File: "+filename+" not found");

	// Read the RDF/XML file
	model.read(in, null);
	
	// Create a new class named "Researcher"
	OntClass researcher = model.createClass(ns+"Researcher");
	
	// ** TASK 6.1: Create a new class named "University" **
	OntClass university = model.createClass(ns + "University");
	
	
	// ** TASK 6.2: Add "Researcher" as a subclass of "Person" **
	OntClass person = model.getOntClass(ns + "Person");
	person.addSubClass(researcher);
	
	
	// ** TASK 6.3: Create a new property named "worksIn" **
	Property worksIn = model.createProperty(ns + "worksIn");
	
	// ** TASK 6.4: Create a new individual of Researcher named "Jane Smith" **
	Individual janeSmith = researcher.createIndividual(ns + "Jane Smith");
	
	// ** TASK 6.5: Add to the individual JaneSmith the fullName, given and family names **
	janeSmith.addLiteral(VCARD.FN, "Jane Smith");
	janeSmith.addLiteral(VCARD.Given, "Jane");
	janeSmith.addLiteral(VCARD.Family, "Smith");
	
	// ** TASK 6.6: Add UPM as the university where John Smith works **		
	Individual johnSmith = model.getIndividual(ns + "JohnSmith");
	Individual upm = university.createIndividual(ns + "UPM");	
	johnSmith.addProperty(worksIn, upm);
	
	
	model.write(System.out, "RDF/XML-ABBREV");
}
 
開發者ID:FacultadInformatica-LinkedData,項目名稱:Curso2014-2015,代碼行數:48,代碼來源:Task06_JoseRodriguezBueno.java

示例9: main

import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
public static void main(String args[])
{
	String filename = "example5.rdf";
	
	// Create an empty model
	OntModel model = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM);
	
	// Use the FileManager to find the input file
	InputStream inStr = FileManager.get().open(filename);

	if (inStr == null)
		throw new IllegalArgumentException("File: "+filename+" not found");

	// Read the RDF/XML file
	model.read(inStr, null);
	
	// Create a new class named "Researcher"
	OntClass researcher = model.createClass(ns + "Researcher");
	
	// ** TASK 6.1: Create a new class named "University" **
	OntClass university = model.createClass(ns + "University");
	
	// ** TASK 6.2: Add "Researcher" as a subclass of "Person" **
	OntClass person = model.createClass(ns + "Person");
	person.addSubClass(researcher);
	
	// ** TASK 6.3: Create a new property named "worksIn" **
	Property worksIn = model.createProperty(ns+"worksIn");
	
	// ** TASK 6.4: Create a new individual of Researcher named "Jane Smith" **
	Individual janeSmith = researcher.createIndividual(ns + "JaneSmith");		
	
	// ** TASK 6.5: Add to the individual JaneSmith the fullName, given and family names **
	janeSmith.addProperty(VCARD.FN, "Jane Smith");
	janeSmith.addProperty(VCARD.Family, "Smith");
	
	
	// ** TASK 6.6: Add UPM as the university where John Smith works **
	Individual upm = university.createIndividual(ns + "UPM");
	Individual johnSmith = model.getIndividual(ns + "JohnSmith");
	johnSmith.addProperty(worksIn, upm);
	
	
	model.write(System.out, "RDF/XML-ABBREV");
}
 
開發者ID:FacultadInformatica-LinkedData,項目名稱:Curso2014-2015,代碼行數:46,代碼來源:Task06_IsaacOlguin.java

示例10: main

import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
public static void main(String args[])
{
	String filename = "example5.rdf";
	
	// Create an empty model
	OntModel model = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM);
	
	// Use the FileManager to find the input file
	InputStream in = FileManager.get().open(filename);

	if (in == null)
		throw new IllegalArgumentException("File: "+filename+" not found");

	// Read the RDF/XML file
	model.read(in, null);
	
	// Create a new class named "Researcher"
	OntClass researcher = model.createClass(ns+"Researcher");
	
	// ** TASK 6.1: Create a new class named "University" **
	OntClass university = model.createClass(ns+"University");
	
	// ** TASK 6.2: Add "Researcher" as a subclass of "Person" **
	model.getOntClass(ns+"Person").addSubClass(model.createClass(ns+"Researcher"));
	
	// ** TASK 6.3: Create a new property named "worksIn" **
	Property worksIn = model.createProperty(ns+"worksIn");
	
	// ** TASK 6.4: Create a new individual of Researcher named "Jane Smith" **
	Individual janeSmith = researcher.createIndividual(ns+"JaneSmith");
	
	// ** TASK 6.5: Add to the individual JaneSmith the fullName, given and family names **
	janeSmith.addProperty(VCARD.FN, "JaneSmith");
	janeSmith.addProperty(VCARD.Given, "Jane");
	janeSmith.addProperty(VCARD.Family, "Smith");
	
	// ** TASK 6.6: Add UPM as the university where John Smith works **
       Individual upm = university.createIndividual(ns + "UPM");
       Individual john = model.getIndividual(ns + "JohnSmith");

       john.addProperty(worksIn, upm);
	
	model.write(System.out, "TURTLE");
}
 
開發者ID:FacultadInformatica-LinkedData,項目名稱:Curso2014-2015,代碼行數:45,代碼來源:cesoriano_Task06.java

示例11: main

import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
public static void main(String args[])
{
	String filename = "src/examples/example5.rdf";
	
	// Create an empty model
	OntModel model = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM);
	
	// Use the FileManager to find the input file
	InputStream in = FileManager.get().open(filename);

	if (in == null)
		throw new IllegalArgumentException("File: "+filename+" not found");

	// Read the RDF/XML file
	model.read(in, null);
	
	// Create a new class named "Researcher"
	OntClass researcher = model.createClass(ns+"Researcher");
	
	// ** TASK 6.1: Create a new class named "University" **
	OntClass university = model.createClass(ns+"University");
	
	// ** TASK 6.2: Add "Researcher" as a subclass of "Person" **
	model.getOntClass(ns+"Person").addSubClass(researcher);
	
	// ** TASK 6.3: Create a new property named "worksIn" **
	Property worksIn = model.createProperty(ns+"worksIn");
	//System.out.println("WorksIn: "+worksIn);
	// ** TASK 6.4: Create a new individual of Researcher named "Jane Smith" **
	Individual janeSmith = researcher.createIndividual(ns+"JaneSmith");
	
	// ** TASK 6.5: Add to the individual JaneSmith the fullName, given and family names **
	janeSmith.addProperty(VCARD.FN, "JaneSmith");
	janeSmith.addProperty(VCARD.Given, "Jane");
	janeSmith.addProperty(VCARD.Family, "Smith");
	
	// ** TASK 6.6: Add UPM as the university where John Smith works **
	Individual johnSmith = model.getIndividual(ns+"JohnSmith");
	Individual upm = university.createIndividual(ns+"UPM");
	//System.out.println("UPM: "+upm);
	//System.out.println("JS: "+johnSmith);

	johnSmith.addProperty(worksIn, upm);
	
	model.write(System.out, "RDF/XML-ABBREV");
}
 
開發者ID:FacultadInformatica-LinkedData,項目名稱:Curso2014-2015,代碼行數:47,代碼來源:Task06_AlbertoMinguito.java

示例12: main

import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
public static void main(String args[])
{
	String filename = "example5.rdf";
	
	// Create an empty model
	OntModel model = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM);
	
	// Use the FileManager to find the input file
	InputStream in = FileManager.get().open(filename);

	if (in == null)
		throw new IllegalArgumentException("File: "+filename+" not found");

	// Read the RDF/XML file
	model.read(in, null);
	
	// Create a new class named "Researcher"
	OntClass researcher = model.createClass(ns+"Researcher");
	
	// ** TASK 6.1: Create a new class named "University" **
	OntClass university = model.createClass(ns+"University");
	
	// ** TASK 6.2: Add "Researcher" as a subclass of "Person" **
	OntClass person = model.createClass(ns + "Person");
	person.addSubClass(researcher);
	
	// ** TASK 6.3: Create a new property named "worksIn" **
	Property worksIn=model.createProperty(ns+"worksIn");
	
	// ** TASK 6.4: Create a new individual of Researcher named "Jane Smith" **
	Individual janeSmith =researcher.createIndividual(ns+"JaneSmith");
	
	// ** TASK 6.5: Add to the individual JaneSmith the fullName, given and family names **
	janeSmith.addLiteral(VCARD.FN, "Jane Smith");
	janeSmith.addLiteral(VCARD.Given, "Jane");
	janeSmith.addLiteral(VCARD.Family, "Smith");
	
	
	// ** TASK 6.6: Add UPM as the university where John Smith works **
	Individual johnSmith = model.getIndividual(ns+"JohnSmith");
	Individual uPM= university.createIndividual(ns+"UPM");
	johnSmith.addProperty(worksIn, uPM);
	
	
	model.write(System.out, "RDF/XML-ABBREV");
}
 
開發者ID:FacultadInformatica-LinkedData,項目名稱:Curso2014-2015,代碼行數:47,代碼來源:Task06_kainruben.java

示例13: main

import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
public static void main(String args[])
{
	String filename = "example5.rdf";
	
	// Create an empty model
	OntModel model = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM);
	
	// Use the FileManager to find the input file
	InputStream in = FileManager.get().open(filename);

	if (in == null)
		throw new IllegalArgumentException("File: "+filename+" not found");

	// Read the RDF/XML file
	model.read(in, null);
	
	// Create a new class named "Researcher"
	OntClass researcher = model.createClass(ns+"Researcher");
	
	// ** TASK 6.1: Create a new class named "University" **
	OntClass university = model.createClass(ns+"University");
	
	// ** TASK 6.2: Add "Researcher" as a subclass of "Person" **
	model.getOntClass(ns+"Person").addSubClass(university);
	
	// ** TASK 6.3: Create a new property named "worksIn" **
	Property worksIn = model.createProperty(ns+"WorksIn");
	
	// ** TASK 6.4: Create a new individual of Researcher named "Jane Smith" **
	Individual janeSmith = researcher.createIndividual(ns+"JaneSmith");
	
	// ** TASK 6.5: Add to the individual JaneSmith the fullName, given and family names **
	janeSmith.addProperty(VCARD.FN, "JaneSmith");
	janeSmith.addProperty(VCARD.Given, "Jane");
	janeSmith.addProperty(VCARD.Family, "Smith");
	
	// ** TASK 6.6: Add UPM as the university where John Smith works **
	Individual johnSmith = model.getIndividual(ns+"JaneSmith");
	johnSmith.addProperty(worksIn, university.createIndividual(ns+"UPM"));
	
	model.write(System.out, "RDF/XML-ABBREV");
	System.out.println("\n---------------------------------------------\n");
	model.write(System.out, "TURTLE");
}
 
開發者ID:FacultadInformatica-LinkedData,項目名稱:Curso2014-2015,代碼行數:45,代碼來源:Task06_Nestor_Lopez.java

示例14: main

import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
public static void main(String args[])
{
	String filename = "example5.rdf";
	
	// Create an empty model
	OntModel model = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM);
	
	// Use the FileManager to find the input file
	InputStream in = FileManager.get().open(filename);

	if (in == null)
		throw new IllegalArgumentException("File: "+filename+" not found");

	// Read the RDF/XML file
	model.read(in, null);
	
	// Create a new class named "Researcher"
	OntClass researcher = model.createClass(ns+"Researcher");
	
	// ** TASK 6.1: Create a new class named "University" **
	
	OntClass univer = model.createClass(ns + "University");

	// ** TASK 6.2: Add "Researcher" as a subclass of "Person" **
	
	model.getOntClass(ns + "Person").addSubClass(researcher);

	// ** TASK 6.3: Create a new property named "worksIn" **
	
	Property worksIn = model.createProperty(ns + "worksIn");

	// ** TASK 6.4: Create a new individual of Researcher named "Jane Smith" **
	
	Individual janeSmith = researcher.createIndividual(ns + "JaneSmith");

	
	// ** TASK 6.5: Add to the individual JaneSmith the fullName, given and family names **
	
	janeSmith.addProperty(VCARD.FN,"Jane Smith");
	janeSmith.addProperty(VCARD.Given,"Jane");
	janeSmith.addProperty(VCARD.Family,"Smith");
	
	// ** TASK 6.6: Add UPM as the university where John Smith works **
	
       Individual johnSmith = model.getIndividual(ns + "JohnSmith");
	Individual upm = univer.createIndividual(ns + "UPM");
       johnSmith.addProperty(worksIn,upm);
	model.write(System.out, "Turtle");
}
 
開發者ID:FacultadInformatica-LinkedData,項目名稱:Curso2014-2015,代碼行數:50,代碼來源:Task06_Tarasyuk.java

示例15: main

import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
public static void main(String args[]) {
    String filename = "/home/alex/GitHub/Curso2014-2015/Assignment3/rdf examples/example5.rdf";

    // Create an empty model
    OntModel model = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM);

    // Use the FileManager to find the input file
    InputStream in = FileManager.get().open(filename);

    if (in == null)
        throw new IllegalArgumentException("File: " + filename + " not found");

    // Read the RDF/XML file
    model.read(in, null);

    // Create a new class named "Researcher"
    OntClass researcher = model.createClass(ns + "Researcher");

    // ** TASK 6.1: Create a new class named "University" **

    OntClass university = model.createClass(ns + "University");

    // ** TASK 6.2: Add "Researcher" as a subclass of "Person" **

    model.getOntClass(ns + "Person").setSubClass(researcher);

    // ** TASK 6.3: Create a new property named "worksIn" **

    Property workIn = model.createProperty(ns + "worksIN");

    // ** TASK 6.4: Create a new individual of Researcher named "Jane Smith" **

    Individual jane = researcher.createIndividual(ns + "janeSmith");

    // ** TASK 6.5: Add to the individual JaneSmith the fullName, given and family names **

    jane.addProperty(VCARD.FN, "Jane Smith");
    jane.addProperty(VCARD.Given, "Jane");
    jane.addProperty(VCARD.Family, "Smith");

    // ** TASK 6.6: Add UPM as the university where John Smith works **
    Individual upm = university.createIndividual(ns + "UPM");
    Individual john = model.getIndividual(ns + "JohnSmith");

    john.addProperty(workIn, upm);

    model.write(System.out, "RDF/XML-ABBREV");
}
 
開發者ID:FacultadInformatica-LinkedData,項目名稱:Curso2014-2015,代碼行數:49,代碼來源:Task06_baraalex.java


注:本文中的com.hp.hpl.jena.ontology.OntModel.getIndividual方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。