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


Java OntModelSpec类代码示例

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


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

示例1: createModel

import com.hp.hpl.jena.ontology.OntModelSpec; //导入依赖的package包/类
/**
 * Create a model with a reasoner set based on the chosen reasoning level.
 * 
 * @param reasoningLevel
 *          The reasoning level for this model
 * 
 * @return The created ontology model
 */
private OntModel createModel(String reasoningLevel) {
  OntModel model;
  int reasoningLevelIndex;

  model = null;

  reasoningLevelIndex = getReasoningLevelIndex(reasoningLevel);

  if (reasoningLevelIndex == 0) { // None
    model = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM);
  } else if (reasoningLevelIndex == 1) { // RDFS
    model = ModelFactory
        .createOntologyModel(OntModelSpec.OWL_DL_MEM_RDFS_INF);
  } else if (reasoningLevelIndex == 2) { // OWL
    final Reasoner reasoner = PelletReasonerFactory.theInstance().create();
    final Model infModel = ModelFactory.createInfModel(reasoner,
        ModelFactory.createDefaultModel());
    model = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM,
        infModel);
  }

  return model;
}
 
开发者ID:DaveRead,项目名称:BasicQuery,代码行数:32,代码来源:RdbToRdf.java

示例2: readOwlFile

import com.hp.hpl.jena.ontology.OntModelSpec; //导入依赖的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.ontology.OntModelSpec; //导入依赖的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.ontology.OntModelSpec; //导入依赖的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.ontology.OntModelSpec; //导入依赖的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.ontology.OntModelSpec; //导入依赖的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.ontology.OntModelSpec; //导入依赖的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: SadlJenaModelGetter

import com.hp.hpl.jena.ontology.OntModelSpec; //导入依赖的package包/类
/**
 * This constructor should be called when the repository format is not known
 * @param _tdbFolder
 */
public SadlJenaModelGetter(IConfigurationManager configMgr, String _tdbFolder) {
	configurationManager = configMgr;
	File tdbFile = new File(_tdbFolder);
	if (tdbFile.exists()) {
		setFormat(IConfigurationManager.JENA_TDB);	// if the caller doesn't tell us the format
													// and the TDB folder exists, use it
	}
	else {
		setFormat(IConfigurationManager.RDF_XML_ABBREV_FORMAT);
	}
	setTdbFolder(_tdbFolder);
 	if (originalModelGetter == null) {
		// save original (file-based) importModelGetter
		originalModelGetter = OntModelSpec.getDefaultSpec(OWL.getURI()).getImportModelGetter();
	}
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:21,代码来源:SadlJenaModelGetter.java

示例9: loadOntModel

import com.hp.hpl.jena.ontology.OntModelSpec; //导入依赖的package包/类
@Override
public OntModel loadOntModel(String owlFilename) {
	try {
		FileInputStream is = new FileInputStream(new File(owlFilename));
		return initOntModel(is, getOwlFormatFromFile(owlFilename));
	} catch (FileNotFoundException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
	boolean savePI = ontModel.getDocumentManager().getProcessImports();
	ontModel.getDocumentManager().setProcessImports(false);
	try {
		ontModel.read(owlFilename, getOwlFormatFromFile(owlFilename));
	}
	finally {
		ontModel.getDocumentManager().setProcessImports(savePI);
	}
	return ontModel;
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:21,代码来源:ConfigurationManagerForIDE.java

示例10: SadlJenaModelGetter

import com.hp.hpl.jena.ontology.OntModelSpec; //导入依赖的package包/类
/**
 * This constructor should be called when the repository format is not known
 * @param _tdbFolder
 * @throws ConfigurationException 
 */
public SadlJenaModelGetter(OntModelSpec spec, String modelFolder) throws ConfigurationException {
	this.modelFolder = modelFolder;
	File modelFolderFile = new File(modelFolder);
	if (!modelFolderFile.exists()) {
		throw new ConfigurationException("Invalid model folder (" + modelFolder + ")passed to SadlJenaModelGetter");
	}
	modelSpec = spec;
	File tdbFile = new File(getTdbFolder());
	if (tdbFile.exists()) {
		setFormat(JENA_TDB);	// if the caller doesn't tell us the format
													// and the TDB folder exists, use it
	}
	else {
		setFormat(RDF_XML_ABBREV_FORMAT);
	}
 	if (originalModelGetter == null) {
		// save original (file-based) importModelGetter
		originalModelGetter = spec.getImportModelGetter();
	}
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:26,代码来源:SadlJenaModelGetter.java

示例11: MetricsProcessor

import com.hp.hpl.jena.ontology.OntModelSpec; //导入依赖的package包/类
public MetricsProcessor(String uri, org.eclipse.emf.ecore.resource.Resource resource, IConfigurationManagerForIDE configMgr, SadlModelProcessor modelProcessor) throws JenaProcessorException, ConfigurationException {
	if (resource == null) {
		throw new JenaProcessorException("MetricsProcessor constructor called with null resource");
	}
	this.modelProcessor = modelProcessor;
	String modelFolder = getModelFolderPath(resource);
	if (modelFolder != null) {
		// for JUnit tests, this will be null
		String fn = modelFolder + "/" + resource.getURI().segment(resource.getURI().segmentCount() - 1);
		baseUri = uri + ".metrics";
		filename = fn + ".metrics.owl";
		setTheJenaModel(ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM));
		this.configMgr = configMgr;
		modelOntology = getTheJenaModel().createOntology(baseUri);
		modelOntology.addComment("SADL model metrics", "en");
	}
	else {
		throw new ConfigurationException("Model folder not found");
	}
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:21,代码来源:MetricsProcessor.java

示例12: buscarUsuarioRdf

import com.hp.hpl.jena.ontology.OntModelSpec; //导入依赖的package包/类
public OutputStream buscarUsuarioRdf(Long id, String urlBase){
	OutputStream ret = new ByteArrayOutputStream();
	OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
	model.setNsPrefix( "trires", Constantes.ONTO_URI );
	
	Usuario usuario = entityManager.find(Usuario.class, id);
	if (usuario != null){
		Resource recurso = model.createResource(Constantes.USUARIO_URI + usuario.getId().toString());
		recurso.addProperty(RDF.type, VocabularioMembro.RDF_TYPE_CLASS);
		recurso.addProperty(VocabularioMembro.ID, usuario.getId().toString());
		recurso.addProperty(VocabularioMembro.DESCRICAO, usuario.getDescricao());
		recurso.addProperty(VocabularioMembro.EMAIL, usuario.getEmail());
		recurso.addProperty(VocabularioMembro.INSTITUICAO, usuario.getInstituicao());
		recurso.addProperty(VocabularioMembro.LINK_LATTES, usuario.getLinkLattes());
		recurso.addProperty(VocabularioMembro.NOME, usuario.getNome());
	}
	
	model.write(ret, "RDF/XML");
	model.close();
	return ret;
}
 
开发者ID:dwws-ufes,项目名称:2014-trires,代码行数:22,代码来源:UsuariosService.java

示例13: listarTodosRdf

import com.hp.hpl.jena.ontology.OntModelSpec; //导入依赖的package包/类
public OutputStream listarTodosRdf(String urlBase){
	OutputStream ret = new ByteArrayOutputStream();
	OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
	model.setNsPrefix( "trires", Constantes.ONTO_URI );
	
	CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
	CriteriaQuery<Usuario> criteriaQuery = criteriaBuilder.createQuery(Usuario.class);
	Root<Usuario> from = criteriaQuery.from(Usuario.class);
	criteriaQuery.select(from);
	List<Usuario> gruposTrabalho = entityManager.createQuery(criteriaQuery).getResultList();
	for (Usuario usuario : gruposTrabalho) {
		Resource recurso = model.createResource(Constantes.USUARIO_URI + usuario.getId().toString());
		recurso.addProperty(RDF.type, VocabularioMembro.RDF_TYPE_CLASS);
		recurso.addProperty(VocabularioMembro.ID, usuario.getId().toString());
		recurso.addProperty(VocabularioMembro.DESCRICAO, usuario.getDescricao());
		recurso.addProperty(VocabularioMembro.EMAIL, usuario.getEmail());
		recurso.addProperty(VocabularioMembro.INSTITUICAO, usuario.getInstituicao());
		recurso.addProperty(VocabularioMembro.LINK_LATTES, usuario.getLinkLattes());
		recurso.addProperty(VocabularioMembro.NOME, usuario.getNome());
	}
	model.write(ret, "RDF/XML");
	model.close();
	return ret;
}
 
开发者ID:dwws-ufes,项目名称:2014-trires,代码行数:25,代码来源:UsuariosService.java

示例14: ConcreteOntology

import com.hp.hpl.jena.ontology.OntModelSpec; //导入依赖的package包/类
public ConcreteOntology(InputStream is) {
  this.model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_RULE_INF);
  model.read(is, null);

  this.defaultNamespace = this.model.getNsPrefixURI("");
  this.commTypes = new HashSet<String>();
  this.commTypes.addAll(this.loadViaOntology("Communication"));

  this.sectionTypes = new HashSet<>();
  this.sectionTypes.addAll(this.loadViaOntology("Section"));

  this.nerTags = new HashSet<>();
  this.nerTags.addAll(this.loadViaOntology("NamedEntityRecognitionTag"));

  this.posTags = new HashSet<>();
  this.posTags.addAll(this.loadViaOntology("PartOfSpeechTag"));
}
 
开发者ID:hltcoe,项目名称:concrete-java,代码行数:18,代码来源:ConcreteOntology.java

示例15: readIFC

import com.hp.hpl.jena.ontology.OntModelSpec; //导入依赖的package包/类
public OntModel readIFC(String filename,String path) throws IOException {
	File file = new File("C:\\M\\xlokia.txt");
	if (!file.exists()) {
		file.createNewFile();
	}

	FileWriter fw = new FileWriter(file.getAbsoluteFile());
	BufferedWriter logfile = new BufferedWriter(fw);

	ByteArrayOutputStream strout = new ByteArrayOutputStream();
	BufferedWriter log = new BufferedWriter(new OutputStreamWriter(strout));
	ExpressReader er = new ExpressReader("c:\\jo\\IFC2X3_Final.exp");
	er.outputRDFS(log);
	IFC_ClassModel m1 = new IFC_ClassModel(filename,
			er.getEntities(), er.getTypes(), "r1");
	m1.listRDF(log, path);

	InputStream is = new ByteArrayInputStream(strout.toString().getBytes());

	OntModel model = ModelFactory
			.createOntologyModel(OntModelSpec.RDFS_MEM_TRANS_INF);
	model.read(is, null, "N3");
	return model;

}
 
开发者ID:jyrkio,项目名称:Open-IFC-to-RDF-converter,代码行数:26,代码来源:IFC2Jena.java


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