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


Java ModelFactory.createOntologyModel方法代碼示例

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


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

示例1: loadDefaultModel

import com.hp.hpl.jena.rdf.model.ModelFactory; //導入方法依賴的package包/類
public static OntModel loadDefaultModel(){
	InputStream in = BodyGeometryTest.class.getClassLoader()
			.getResourceAsStream("Duplex_A_20110505.ttl");
	Model model=ModelFactory.createDefaultModel();
	model.read(in,null,"TTL");
	InputStream ins = BodyGeometryTest.class.getClassLoader()
			.getResourceAsStream("IFC2X3_TC1.ttl");
	InputStream input = BodyGeometryTest.class.getClassLoader()
			.getResourceAsStream("Duplex_A_20110505_geometry.ttl");
	Model geometryModel=ModelFactory.createDefaultModel();
	geometryModel.read(input,null,"TTL");
	Model schema=ModelFactory.createDefaultModel();
	schema.read(ins,null,"TTL");	
		try {
			BimSPARQL.init(model,geometryModel);
		} catch (ClassNotFoundException | IOException | ParserConfigurationException | SAXException
				| URISyntaxException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	OntModel ontology=ModelFactory.createOntologyModel();
	ontology.add(schema);
	ontology.add(model);
	ontology.add(geometryModel);
	return ontology;
}
 
開發者ID:BenzclyZhang,項目名稱:BimSPARQL,代碼行數:27,代碼來源:QueryFunctionTest.java

示例2: readOwlFile

import com.hp.hpl.jena.rdf.model.ModelFactory; //導入方法依賴的package包/類
static void readOwlFile (String pathToOwlFile) {
        OntModel ontologyModel =
                ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, null);
        ontologyModel.read(pathToOwlFile, "RDF/XML-ABBREV");
       // OntClass myClass = ontologyModel.getOntClass("namespace+className");

        OntClass myClass = ontologyModel.getOntClass(ResourcesUri.nwr+"domain-ontology#Motion");
        System.out.println("myClass.toString() = " + myClass.toString());
        System.out.println("myClass.getSuperClass().toString() = " + myClass.getSuperClass().toString());

        //List list =
              //  namedHierarchyRoots(ontologyModel);


       Iterator i = ontologyModel.listHierarchyRootClasses()
                .filterDrop( new Filter() {
                    public boolean accept( Object o ) {
                        return ((Resource) o).isAnon();
                    }} ); ///get all top nodes and excludes anonymous classes

       // Iterator i = ontologyModel.listHierarchyRootClasses();
        while (i.hasNext()) {
            System.out.println(i.next().toString());
/*            OntClass ontClass = ontologyModel.getOntClass(i.next().toString());
            if (ontClass.hasSubClass()) {

            }*/
        }

        String q = createSparql("event", "<http://www.newsreader-project.eu/domain-ontology#Motion>");
        System.out.println("q = " + q);
        QueryExecution qe = QueryExecutionFactory.create(q,
                ontologyModel);
        for (ResultSet rs = qe.execSelect() ; rs.hasNext() ; ) {
            QuerySolution binding = rs.nextSolution();
            System.out.println("binding = " + binding.toString());
            System.out.println("Event: " + binding.get("event"));
        }

        ontologyModel.close();
    }
 
開發者ID:newsreader,項目名稱:StreamEventCoreference,代碼行數:42,代碼來源:OwlReader.java

示例3: testSomeMethod2

import com.hp.hpl.jena.rdf.model.ModelFactory; //導入方法依賴的package包/類
@Test
public void testSomeMethod2() throws Exception {
  Dataset ds = TDBFactory.createDataset("/scratch/WORK2/jena/dataset2/");
  
  OntModel model1 = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, ds.getNamedModel("vijaym1"));
  OntModel model2 = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, ds.getNamedModel("vijaym2"));
  OntClass thing = model1.createClass("http://www.w3.org/2002/07/owl#Thing");
  model1.createIndividual("http://example.com/onto1#VijayRaj", thing);
  model2.createIndividual("http://example.;cegilovcom/onto2#VijayRaj", thing);
  Model m = model1.union(model2);
  
  FileWriter fw = new FileWriter("/scratch/WORK2/jena/testModels/mergetestds.xml");
  RDFDataMgr.write(fw, ds, RDFFormat.NQUADS_UTF8);
  

}
 
開發者ID:vijayrajak,項目名稱:JenaKBClient,代碼行數:17,代碼來源:KBIndividualImplTest.java

示例4: CSVSToRDFConverter

import com.hp.hpl.jena.rdf.model.ModelFactory; //導入方法依賴的package包/類
public CSVSToRDFConverter(String sourceFilesDir, String className, String baseNameSpace, String separator,
		String textFieldSeparator, int keyColIndex) {

	nsTBox = baseNameSpace + "model#";
	nsABox = baseNameSpace + "data#";

	this.sourceFilesDir = sourceFilesDir;
	this.className = className;
	this.separator = separator;
	this.textFieldSeparator = textFieldSeparator;

	tboxModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, null);
	aboxModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, null);

	pathSeparator = System.getProperty("file.separator");
	this.keyColIndex = keyColIndex;
}
 
開發者ID:sll-mdilab,項目名稱:t5-doc,代碼行數:18,代碼來源:CSVSToRDFConverter.java

示例5: writeUserEntries

import com.hp.hpl.jena.rdf.model.ModelFactory; //導入方法依賴的package包/類
/**
 * Writes the user entities to rdf
 */
private static OntModel writeUserEntries() {
	OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
	try {
		thewebsemantic.Bean2RDF writer = new Bean2RDF(model);
		InitialContext ic = new InitialContext();
		UserService userService = (UserService) ic.lookup("java:module/UserService");
		List<User> users = userService.getAll();
		for (User u : users) {
			writer.save(u);
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
	return model;
}
 
開發者ID:U-QASAR,項目名稱:u-qasar.platform,代碼行數:19,代碼來源:UQasarUtil.java

示例6: writeProjectEntries

import com.hp.hpl.jena.rdf.model.ModelFactory; //導入方法依賴的package包/類
/**
 * Writes the project entities to rdf
 */
private static OntModel writeProjectEntries() {
	OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
	try {
		thewebsemantic.Bean2RDF writer = new Bean2RDF(model);
		InitialContext ic = new InitialContext();
		TreeNodeService treeNodeService = (TreeNodeService) ic.lookup("java:module/TreeNodeService");
		List<Project> projects = treeNodeService.getAllProjects();
		for (Project proj : projects) {
			writer.save(proj);
		}

	} catch (Exception e) {
		e.printStackTrace();
	}
	return model;
}
 
開發者ID:U-QASAR,項目名稱:u-qasar.platform,代碼行數:20,代碼來源:UQasarUtil.java

示例7: readSemanticModelFiles

import com.hp.hpl.jena.rdf.model.ModelFactory; //導入方法依賴的package包/類
/**
	 * Read the RDF model from files.
	 */
	public static void readSemanticModelFiles() {
		logger.debug("Reading the model from a file");
		// Read the model to an existing model
		String dataDir = UQasarUtil.getDataDirPath();
		String modelPath = "file:///" + dataDir + ONTOLOGYFILE;
//		String modelPath = "file:///C:/nyrhinen/Programme/jboss-as-7.1.1.Final/standalone/data/uq-ontology-model.rdf";

		OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
		RDFDataMgr.read(model, modelPath);
		// Test output to standard output
		//		RDFDataMgr.write(System.out, uqModel, RDFFormat.RDFXML_PRETTY);
		logger.debug("Model read from file " +modelPath);
		UQasarUtil.setUqModel(model);
		System.out.println("Reading done.");
	}
 
開發者ID:U-QASAR,項目名稱:u-qasar.platform,代碼行數:19,代碼來源:UQasarUtil.java

示例8: findAllLabels

import com.hp.hpl.jena.rdf.model.ModelFactory; //導入方法依賴的package包/類
public LinkedList<SemanticConcept> findAllLabels(String ontologyUri,String rootClass){
    
    LinkedList<SemanticConcept> list = new LinkedList<>();
    
    try{
    
        //Create a reasoner
        OntModel model = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);

        //Create new URL of ontology
        URL url = new URL(ontologyUri);
    
        //Create model for the ontology
        model.read(url.openStream(),null);
    
        //Load model to the reasoner
        model.prepare();
    
        //Compute the classification tree
        ((PelletInfGraph) model.getGraph()).getKB().classify();
        
        //Set OWL root element (e.g., it could be thing: model.getOntClass(OWL.Thing.getURI()))
        OntClass owlRoot = model.getOntClass(rootClass);
        
        SemanticConcept sc = new SemanticConcept();
        sc.setUrl(owlRoot.getURI());
        sc.setName("");
        sc.setSemanticSimilarity("");
        list.add(sc);
    
        //For each subclass (direct or indirect)
        for (Iterator it = owlRoot.listSubClasses(false); it.hasNext();) {

            OntClass subclass = (OntClass) it.next();

            //If subclass is not anonymous
            if (!subclass.isAnon()) {

                //If subclass is not nothing
                if(!subclass.getURI().equals(com.hp.hpl.jena.vocabulary.OWL.Nothing.getURI())){
                    
                    sc = new SemanticConcept();
                    sc.setUrl(subclass.getURI());
                    sc.setName("");
                    sc.setSemanticSimilarity("");
                
                    list.add(sc);
                }
            }
        }
        
    }catch(IOException ex){}
    
    return list;
    
}
 
開發者ID:usplssb,項目名稱:SemanticSCo,代碼行數:57,代碼來源:SemanticReasoner.java

示例9: readModel

import com.hp.hpl.jena.rdf.model.ModelFactory; //導入方法依賴的package包/類
protected OntModel readModel() {
  Reasoner reasoner = PelletReasonerFactory.theInstance().create();
  Model infModel = ModelFactory.createInfModel(reasoner, ModelFactory.createDefaultModel());
  OntModel ontModel = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC, infModel);
  ontModel.read(getClass().getResourceAsStream("/" + modelBase), null, TTL);
  return ontModel;
}
 
開發者ID:mehmandarov,項目名稱:zebra-puzzle-workshop,代碼行數:8,代碼來源:Exercise4.java

示例10: readModel

import com.hp.hpl.jena.rdf.model.ModelFactory; //導入方法依賴的package包/類
protected OntModel readModel(String modelInput) {
    Reasoner reasoner = PelletReasonerFactory.theInstance().create();
    Model infModel = ModelFactory.createInfModel(reasoner, ModelFactory.createDefaultModel());
    OntModel ontModel = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC, infModel);
    ontModel.read(getClass().getResourceAsStream("/" + modelInput), null, TTL);
    return ontModel;
}
 
開發者ID:mehmandarov,項目名稱:zebra-puzzle-workshop,代碼行數:8,代碼來源:Exercise32.java

示例11: OntoManager

import com.hp.hpl.jena.rdf.model.ModelFactory; //導入方法依賴的package包/類
private OntoManager() {
    model = ModelFactory.createOntologyModel();  //OntModelSpec.OWL_MEM_RULE_INF
    Properties p=PropertyHolder.getProperties();
    String path=p.getProperty("owlFile") ;
    try {
        remoteUrl = new URL(p.getProperty("remoteUrl"));               //"http://www.co-ode.org/ontologies/pizza/pizza.owl"
    } catch (MalformedURLException e) {
        e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
    }


    localFile = new File(path);         //  /product-ontology-1.1/

}
 
開發者ID:sasinda,項目名稱:OntologyBasedInormationExtractor,代碼行數:15,代碼來源:OntoManager.java

示例12: getOntologyIRI

import com.hp.hpl.jena.rdf.model.ModelFactory; //導入方法依賴的package包/類
public String getOntologyIRI() {

        OntModel mBase = ModelFactory.createOntologyModel(
                OntModelSpec.OWL_MEM, model.getBaseModel());

        String ontIri = null;
        for (Iterator i = mBase.listOntologies(); i.hasNext(); ) {
            Ontology ont = (Ontology) i.next();
            ontIri = ont.getURI();
        }
        return ontIri;
    }
 
開發者ID:sasinda,項目名稱:OntologyBasedInormationExtractor,代碼行數:13,代碼來源:OntoManager.java

示例13: main

import com.hp.hpl.jena.rdf.model.ModelFactory; //導入方法依賴的package包/類
public static void main(String[] args)
	throws ClassNotFoundException, IOException, ParserConfigurationException, SAXException, URISyntaxException {
Model model = ModelFactory.createDefaultModel();
InputStream in = FireSeparationDistance.class.getClassLoader().getResourceAsStream("lifeline_final.ttl");
model.read(in, null, "TTL");
System.out.println(model.size());
Model geometryModel = ModelFactory.createDefaultModel();
InputStream ing = FireSeparationDistance.class.getClassLoader().getResourceAsStream("lifeline_final_geometry.ttl");
geometryModel.read(ing, null, "TTL");
System.out.println(geometryModel.size());
Model schema=loadModel("IFC2X3_TC1.ttl","TTL");
BimSPARQL.init(model, geometryModel);
Model ibcspin = ModelFactory.createDefaultModel();
addMagicProperty(ibcspin, IBC+"hasFireSeparationDistance", prefixes+hasFireSeparationDistance, 1);
addMagicProperty(ibcspin, IBC+"hasProtectedOpeningArea", prefixes+hasProtectedOpeningArea, 1);
addMagicProperty(ibcspin, IBC+"hasUnprotectedOpeningArea", prefixes+hasUnprotectedOpeningArea, 1);
addMagicProperty(ibcspin, IBC+"hasAp", prefixes+hasAp, 1);
addMagicProperty(ibcspin, IBC+"hasAu", prefixes+hasAu, 1);
Model ibc=loadIbcData();
SPINModuleRegistry.get().registerAll(ibc, null);
for (Function f:SPINModuleRegistry.get().getFunctions())
{
	System.out.println(f.getURI());
}
com.hp.hpl.jena.query.Query query = QueryFactory.create(prefixes + mainQuery);

OntModel union = ModelFactory.createOntologyModel();
union.add(schema);
union.add(model);
union.add(geometryModel);
union.add(ibc);
System.out.println(union.size());
QueryExecution qe = QueryExecutionFactory.create(query, union);
com.hp.hpl.jena.query.ResultSet result = qe.execSelect();
      ResultSetFormatter.out(result);

      }
 
開發者ID:BenzclyZhang,項目名稱:BimSPARQL,代碼行數:38,代碼來源:FireSeparationDistance.java

示例14: executePublishing

import com.hp.hpl.jena.rdf.model.ModelFactory; //導入方法依賴的package包/類
@Override
public void executePublishing() throws Exception {
	super.executeImport();
	SDBConnection conn = new SDBConnection(jenaDataSource);
	StoreDesc storeDesc = new StoreDesc(LayoutType.LayoutTripleNodesHash, BygleSystemUtils.getDBType(databaseType));
	Store store = SDBFactory.connectStore(conn, storeDesc);
	if (!StoreUtils.isFormatted(store))
		store.getTableFormatter().create();
	File importDir = new File(importDirectory);
	FileFilter fileFilter = new WildcardFileFilter("*.nt");
	File[] importFiles = importDir.listFiles(fileFilter);
	if (importFiles.length > 0) {
		OntModel ontModel = ModelFactory.createOntologyModel();
		FileFilter ontologyFileFilter = new WildcardFileFilter("*.owl");
		File[] ontologyfiles = importDir.listFiles(ontologyFileFilter);
		for (int x = 0; x < ontologyfiles.length; x++) {
			FileManager.get().readModel(ontModel, ontologyfiles[x].getAbsolutePath());
		}
		System.out.println("##############################STARTING PUBLISHING#############################");
		for (int i = 0; i < importFiles.length; i++) {
			Model modelTpl = ModelFactory.createDefaultModel();
			FileManager.get().readModel(modelTpl, importFiles[i].getAbsolutePath());
			System.out.println("PUBLISHING  FILE " + importFiles[i].getName());
			System.out.println("##############################START SAVING DATA###############################");
			ontModel.add(modelTpl);
		}
		Dataset dataset = SDBFactory.connectDataset(store);
		dataset.getDefaultModel().add(ontModel);
		store.getConnection().close();
		store.close();
		System.out.println("##############################END PUBLISHING##################################");
		FileUtils.cleanDirectory(importDir);
		System.out.println("##############################PUBLISHING SUCCESS##############################");
	} else {
		System.out.println("##############################NO FILES TO PUBLISH##############################");
	}
}
 
開發者ID:regestaexe,項目名稱:bygle-ldp,代碼行數:38,代碼來源:JenaEndPointManager.java

示例15: getContextModel

import com.hp.hpl.jena.rdf.model.ModelFactory; //導入方法依賴的package包/類
public static OntModel getContextModel(Context ctx) {
  if (contextModelMap.containsKey(ctx)) {
    return contextModelMap.get(ctx);
  } else {
    OntModel tempModel = ModelFactory.createOntologyModel(
            OntModelSpec.OWL_MEM, ds.getNamedModel(((ContextImpl)ctx).getCore().getURI()));
    contextModelMap.put(ctx, tempModel);
    return tempModel;
  }
}
 
開發者ID:vijayrajak,項目名稱:JenaKBClient,代碼行數:11,代碼來源:KBObjectImpl.java


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