当前位置: 首页>>代码示例>>Java>>正文


Java OntClass.createIndividual方法代码示例

本文整理汇总了Java中com.hp.hpl.jena.ontology.OntClass.createIndividual方法的典型用法代码示例。如果您正苦于以下问题:Java OntClass.createIndividual方法的具体用法?Java OntClass.createIndividual怎么用?Java OntClass.createIndividual使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.hp.hpl.jena.ontology.OntClass的用法示例。


在下文中一共展示了OntClass.createIndividual方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的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" **
	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 **

	// create an instance of university for upm
	Individual upm = university.createIndividual(ns+"UPM");
	// complete the property
	model.getIndividual(ns+"JohnSmith").addProperty(worksIn, upm);
	
	model.write(System.out, "TURTLE");
}
 
开发者ID:FacultadInformatica-LinkedData,项目名称:Curso2014-2015,代码行数:46,代码来源:Task06_JorgeGonzalez.java

示例2: main

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的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.createClass(ns+"Person");
	researcher.addSubClass(person);
	
	// ** TASK 6.3: Create a new property named "worksIn" **
	Property trabajaEn = model.createProperty(ns, "worksIn"); // hasName property
	
	// ** TASK 6.4: Create a new individual of Researcher named "Jane Smith" **
	Individual persona1 = researcher.createIndividual(ns+"Jane Smith");
	
	// ** TASK 6.5: Add to the individual JaneSmith the fullName, given and family names **
	persona1.addProperty(VCARD.FN, "Jane Smith"); //FN -> Full name
	persona1.addProperty(VCARD.Family, "Smith"); //Family -> Apellido
	persona1.addProperty(VCARD.Given, "Jane");	//Given -> Nombre
	
	// ** TASK 6.6: Add UPM as the university where John Smith works **
	Individual upm = university.createIndividual(ns+"UPM");
	persona1.addProperty(trabajaEn, upm);
	
	model.write(System.out, "RDF/XML-ABBREV");
}
 
开发者ID:FacultadInformatica-LinkedData,项目名称:Curso2014-2015,代码行数:44,代码来源:Task06_Marco_Lopez.java

示例3: main

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的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.OntClass; //导入方法依赖的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.OntClass; //导入方法依赖的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" **
	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 **
	model.getIndividual(ns+"JohnSmith").addProperty( worksin,
						university.createIndividual(ns+"UPM") );
	
	model.write(System.out, "TURTLE");
}
 
开发者ID:FacultadInformatica-LinkedData,项目名称:Curso2014-2015,代码行数:43,代码来源:vktrsm_Task06.java

示例6: main

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的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

示例7: main

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的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

示例8: main

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的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

示例9: main

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的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

示例10: main

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的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

示例11: main

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的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

示例12: main

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {
	
	String filename = "example6.rdf";
	String namespace = "www.example.org/resources#";
	
	// 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);
       
       // Task 6.1: Create a new class named "Researcher"
       //			 Create a new class named "University"
       OntClass researcher = model.createClass(namespace + "Researcher");
       OntClass university = model.createClass(namespace + "University");
       
       // Task 6.2: Add "Researcher" as a subclass of "Person"
       model.getOntClass(namespace + "Person").addSubClass(researcher);
       
       // Task 6.3: Create a new property named "worksIn"
       Property worksIn = model.createProperty(namespace + "worksIn");
       
       // Task 6.4: Create a new individual of Researcher named "Jane Smith"
       Individual janeSmith = researcher.createIndividual(namespace + "JaneSmith");
       
       // Task 6.5: Add to the individual JaneSmith the fullName, given and family names
       janeSmith.addProperty(VCARD.FN, 	"Jane Smith")
       		 .addProperty(VCARD.Given, 	"Smith")
       		 .addProperty(VCARD.Family, "Smith");
       
       // Task 6.6: Add UPM as the university where John Smith works
       Individual UPM = university.createIndividual(namespace + "UPM");
       model.getIndividual(namespace + "JohnSmith").addProperty(worksIn, UPM);
       
       // Print model to stdout
       model.write(System.out, "RDF/XML-ABBREV");
}
 
开发者ID:FacultadInformatica-LinkedData,项目名称:Curso2014-2015,代码行数:47,代码来源:Task06_pdoro.java

示例13: main

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的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.OntClass; //导入方法依赖的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.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");
       model.getIndividual(ns + "JohnSmith").addProperty(worksIn, upm);
	
	model.write(System.out, "RDF/XML-ABBREV");
}
 
开发者ID:FacultadInformatica-LinkedData,项目名称:Curso2014-2015,代码行数:44,代码来源:Task06aydee.java

示例15: main

import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的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(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.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 upm = university.createIndividual(ns+"UPM");
		
		model.getIndividual(ns+"JohnSmith").addProperty(worksIn, upm);
		
	
		
	
	model.write(System.out, "RDF/XML-ABBREV");
}
 
开发者ID:FacultadInformatica-LinkedData,项目名称:Curso2014-2015,代码行数:52,代码来源:MiguelOrtegaMoreno_Task06.java


注:本文中的com.hp.hpl.jena.ontology.OntClass.createIndividual方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。