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


Java OntModel类代码示例

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


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

示例1: processSingle

import org.apache.jena.ontology.OntModel; //导入依赖的package包/类
private void processSingle(OntModel m) {
  for (Iterator<?> i = m.listClasses(); i.hasNext(); ) {
    OntClass c = (OntClass) i.next();
    try {
      // too confusing to list all the restrictions as root classes 
      if (c.isAnon()) {
        continue;
      }

      if (c.hasSuperClass(m.getProfile().THING(), true) || c.getCardinality(m.getProfile().SUB_CLASS_OF()) == 0) {
        // this class is directly descended from Thing
        roots.add(c);
      }
    } catch (Exception e) {
      Log.error("Error during extraction or root Classes from Ontology Model: ", e);
    }
  }
}
 
开发者ID:apache,项目名称:incubator-sdap-mudrod,代码行数:19,代码来源:OwlParser.java

示例2: inferClasses

import org.apache.jena.ontology.OntModel; //导入依赖的package包/类
@Override
public Set<URI> inferClasses(final URI uri, final WebResource resource, final Ontology ontology) {

    final OntModel model = resolveImports(ont(ontology));
    model.add(parse(resource));

    final Individual individual = model.getIndividual(uri.toString());

    if (individual != null) {
        return individual
                .listRDFTypes(false)
                .filterKeep(Resource::isURIResource)
                .mapWith(Resource::getURI)
                .mapWith(URI::create)
                .toSet();
    } else {
        LOG.info("<{}> does not make any statements about itself, " +
                "so we can't infer anything about it nor bind extensions to it", uri);
        return Collections.emptySet();
    }

}
 
开发者ID:fcrepo4-labs,项目名称:fcrepo-api-x,代码行数:23,代码来源:JenaOntologyService.java

示例3: transitiveImportsTest

import org.apache.jena.ontology.OntModel; //导入依赖的package包/类
@Test
public void transitiveImportsTest() throws Exception {
    final OntModel transitive = toTest.getOntology(URI.create(ONT5)).model;

    // 5 includes 4, 4 includes 1
    final Model expectedTriples = ModelFactory.createDefaultModel();
    expectedTriples.add(ModelFactory.createDefaultModel().read(ONTOLOGY_REGISTRY.get(URI.create(ONT1))
            .representation(), null, "N-TRIPLES"));
    expectedTriples.add(ModelFactory.createDefaultModel().read(ONTOLOGY_REGISTRY.get(URI.create(ONT4))
            .representation(), null, "N-TRIPLES"));
    expectedTriples.add(ModelFactory.createDefaultModel().read(ONTOLOGY_REGISTRY.get(URI.create(ONT5))
            .representation(), null, "N-TRIPLES"));

    expectedTriples.removeAll(null, expectedTriples.getProperty(OWL_IMPORTS), null);

    assertTrue(transitive.containsAll(expectedTriples));
}
 
开发者ID:fcrepo4-labs,项目名称:fcrepo-api-x,代码行数:18,代码来源:JenaOntologyServiceTest.java

示例4: loadOntologyTest

import org.apache.jena.ontology.OntModel; //导入依赖的package包/类
@Test
public void loadOntologyTest() {
    final WebResource resource = ONTOLOGY_REGISTRY.get(URI.create(ONT5));

    final OntModel transitive = toTest.parseOntology(resource).model;

    // 5 includes 4, 4 includes 1
    final Model expectedTriples = ModelFactory.createDefaultModel();
    expectedTriples.add(ModelFactory.createDefaultModel().read(ONTOLOGY_REGISTRY.get(URI.create(ONT1))
            .representation(), null, "N-TRIPLES"));
    expectedTriples.add(ModelFactory.createDefaultModel().read(ONTOLOGY_REGISTRY.get(URI.create(ONT4))
            .representation(), null, "N-TRIPLES"));
    expectedTriples.add(ModelFactory.createDefaultModel().read(ONTOLOGY_REGISTRY.get(URI.create(ONT5))
            .representation(), null, "N-TRIPLES"));

    expectedTriples.removeAll(null, expectedTriples.getProperty(OWL_IMPORTS), null);

    assertTrue(transitive.containsAll(expectedTriples));

}
 
开发者ID:fcrepo4-labs,项目名称:fcrepo-api-x,代码行数:21,代码来源:JenaOntologyServiceTest.java

示例5: map

import org.apache.jena.ontology.OntModel; //导入依赖的package包/类
@Override
public void map(List<DIF> pojoList, Properties props) {
  // create the base model
  OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
  ontModel.setNsPrefix("dif_v9.8.2", MUDROD_GCMD_DIF_9_8_2);
  ontModel.setNsPrefix("geo", "http://www.opengis.net/ont/geosparql#");
  ontModel.read(SWEET_REPR_DATA_PRODUCT, null, "TURTLE");

  // get the https://sweetontology.net/reprDataProduct/Dataset class reference
  Resource dataset = ontModel.getResource(SWEET_REPR_DATA_PRODUCT_NS + "Dataset");
  // create the https://sweetontology.net/reprDataProduct/PODAACDataset class
  // reference
  OntClass podaacDataset = ontModel.createClass(PODAAC_DATASET + "PODAACDataset");
  // make PODAACDataset a subclass of Dataset
  podaacDataset.addSuperClass(dataset);
  // create an individual for each DIF POJO
  for (DIF dif : pojoList) {
    Individual gcmdDif = podaacDataset.createIndividual(PODAAC_DATASET + dif.getEntryID());
    buildIndividual(ontModel, dif, gcmdDif);
  }
  writeOntologyModel(ontModel, props);
}
 
开发者ID:ESIPFed,项目名称:eskg,代码行数:23,代码来源:PODAACOntologyMapper.java

示例6: loadCnt

import org.apache.jena.ontology.OntModel; //导入依赖的package包/类
private void loadCnt() {
    if (cnt != null) {
        return;
    }
    OntModel ontModel = loadOntologyFromClasspath("content.owl", CNT);    
    
    bytes = ontModel.getDatatypeProperty(CNT + "bytes");
    chars = ontModel.getDatatypeProperty(CNT + "chars");
    characterEncoding = ontModel.getDatatypeProperty(CNT + "characterEncoding");
    
    ContentAsText = ontModel.getOntClass(CNT + "ContentAsText");
    ContentAsBase64 = ontModel.getOntClass(CNT + "ContentAsBase64");
    checkNotNull(ontModel, bytes, chars, characterEncoding, ContentAsText, ContentAsBase64);
    cnt = ontModel;
    
}
 
开发者ID:apache,项目名称:incubator-taverna-engine,代码行数:17,代码来源:TavernaProvModel.java

示例7: loadTavernaProv

import org.apache.jena.ontology.OntModel; //导入依赖的package包/类
protected synchronized void loadTavernaProv() {
    if (tavernaProv != null) {
        return;
    }
    OntModel ontModel = loadOntologyFromClasspath(TAVERNAPROV_TTL, TAVERNAPROV);    
    
    content = ontModel.getObjectProperty(TAVERNAPROV + "content");        
    
    byteCount = ontModel.getDatatypeProperty(TAVERNAPROV + "byteCount");
    sha1 = ontModel.getDatatypeProperty(TAVERNAPROV + "sha1");
    sha512 = ontModel.getDatatypeProperty(TAVERNAPROV + "sha512");
    stackTrace = ontModel.getDatatypeProperty(TAVERNAPROV + "stackTrace");
    errorMessage = ontModel.getDatatypeProperty(TAVERNAPROV + "errorMessage");
    
    Content = ontModel.getOntClass(TAVERNAPROV + "Content");
    Error = ontModel.getOntClass(TAVERNAPROV + "Error");
    TavernaEngine = ontModel.getOntClass(TAVERNAPROV + "TavernaEngine");
    
    checkNotNull(ontModel, content, Content, byteCount,sha1, sha512, stackTrace, errorMessage, Content, Error, TavernaEngine);
    tavernaProv = ontModel;            
}
 
开发者ID:apache,项目名称:incubator-taverna-engine,代码行数:22,代码来源:TavernaProvModel.java

示例8: loadOntologyFromClasspath

import org.apache.jena.ontology.OntModel; //导入依赖的package包/类
protected OntModel loadOntologyFromClasspath(String classPathUri, String uri) {
    
    OntModel ontModel = ModelFactory.createOntologyModel();

    // Load from classpath
    InputStream inStream = getClass().getResourceAsStream(classPathUri);
    if (inStream == null) {
        throw new IllegalArgumentException("Can't load " + classPathUri);
    }
    // Ontology ontology = ontModel.createOntology(uri);
    if (classPathUri.endsWith(".ttl")) {
        ontModel.read(inStream, uri, "TURTLE");
    } else {
        ontModel.read(inStream, uri);
    }
    return ontModel;
}
 
开发者ID:apache,项目名称:incubator-taverna-engine,代码行数:18,代码来源:ProvModel.java

示例9: loadProvDictionary

import org.apache.jena.ontology.OntModel; //导入依赖的package包/类
protected synchronized void loadProvDictionary() {
    if (provDict != null) {
        return;
    }
    OntModel ontModel = loadOntologyFromClasspath(PROV_DICTIONARY_TTL,
            PROV_DICTIONARY);

    hadDictionaryMember = ontModel.getObjectProperty(PROV
            + "hadDictionaryMember");
    pairEntity = ontModel.getObjectProperty(PROV + "pairEntity");
    pairKey = ontModel.getDatatypeProperty(PROV + "pairKey");

    Dictionary = ontModel.getOntClass(PROV + "Dictionary");
    EmptyDictionary = ontModel.getOntClass(PROV + "EmptyDictionary");
    KeyEntityPair = ontModel.getOntClass(PROV + "KeyEntityPair");

    checkNotNull(ontModel, hadDictionaryMember, pairEntity, pairKey,
            Dictionary, EmptyDictionary, KeyEntityPair);

    provDict = ontModel;
}
 
开发者ID:apache,项目名称:incubator-taverna-engine,代码行数:22,代码来源:ProvModel.java

示例10: loadWfDesc

import org.apache.jena.ontology.OntModel; //导入依赖的package包/类
protected synchronized void loadWfDesc() {
        if (wfdesc != null) {
            return;
        }
        OntModel ontModel = loadOntologyFromClasspath(WFDESC_OWL, WFDESC);  
        
        hasSubProcess = ontModel.getObjectProperty(WFDESC + "hasSubProcess");
        Input = ontModel.getOntClass(WFDESC + "Input");
//      Input.addSuperClass(Role);
        Output = ontModel.getOntClass(WFDESC + "Output");
//    Output.addSuperClass(Role);

        Process = ontModel.getOntClass(WFDESC + "Process");
        Workflow = ontModel.getOntClass(WFDESC + "Workflow");
        checkNotNull(ontModel, hasSubProcess, Process, Workflow, Input, Output);

        wfdesc = ontModel;
    }
 
开发者ID:apache,项目名称:incubator-taverna-engine,代码行数:19,代码来源:WfprovModel.java

示例11: fixOntModel

import org.apache.jena.ontology.OntModel; //导入依赖的package包/类
public OntModel fixOntModel(OntModel ontModel)
    {
        if (ontModel == null) throw new IllegalArgumentException("Model cannot be null");
        
        OntModel fixedModel = ModelFactory.createOntologyModel(ontModel.getSpecification());
        Query fix = QueryFactory.create("CONSTRUCT\n" +
"{\n" +
"  ?s ?p ?o\n" +
"}\n" +
"WHERE\n" +
"{\n" +
"  ?s ?p ?o\n" +
"  FILTER (!(?p = <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> && ?o = <https://www.w3.org/ns/ldt#Constraint>))\n" +
"}");
        
        try (QueryExecution qex = QueryExecutionFactory.create(fix, ontModel))
        {
            fixedModel.add(qex.execConstruct());
        }
        
        return fixedModel;
    }
 
开发者ID:AtomGraph,项目名称:Processor,代码行数:23,代码来源:Validator.java

示例12: loadDCT

import org.apache.jena.ontology.OntModel; //导入依赖的package包/类
protected synchronized void loadDCT() {
	if (dct != null)
		return;

	OntModel ontModel = loadOntologyFromClasspath(
			"/ontologies/dcterms_od.owl",
			"http://purl.org/wf4ever/dcterms_od");

	// properties from dct
	standard = ontModel.getOntClass(DCT + "Standard");
	conformsTo = ontModel.getObjectProperty(DCT + "conformsTo");

	// We'll cheat dc:format in
	format = ontModel
			.createDatatypeProperty("http://purl.org/dc/elements/1.1/"
					+ "format");
	checkNotNull(standard, conformsTo, format);

	dct = ontModel;
}
 
开发者ID:apache,项目名称:incubator-taverna-language,代码行数:21,代码来源:RDFToManifest.java

示例13: loadOntologyFromClasspath

import org.apache.jena.ontology.OntModel; //导入依赖的package包/类
protected OntModel loadOntologyFromClasspath(String classPathUri, String uri) {
	OntModel ontModel = createOntologyModel();

	// Load from classpath
	InputStream inStream = getClass().getResourceAsStream(classPathUri);
	if (inStream == null)
		throw new IllegalArgumentException("Can't load " + classPathUri);
	// Ontology ontology = ontModel.createOntology(uri);
	ontModel.read(inStream, uri);
	try {
		inStream.close();
	} catch (IOException e) {
		// Shouldn't happen
	}
	return ontModel;
}
 
开发者ID:apache,项目名称:incubator-taverna-language,代码行数:17,代码来源:RDFToManifest.java

示例14: loadORE

import org.apache.jena.ontology.OntModel; //导入依赖的package包/类
protected synchronized void loadORE() {
	if (ore != null)
		return;
	OntModel ontModel = loadOntologyFromClasspath(
			"/ontologies/ore-owl.owl", "http://purl.org/wf4ever/ore-owl");
	aggregation = ontModel.getOntClass(ORE + "Aggregation");

	aggregates = ontModel.getObjectProperty(ORE + "aggregates");
	proxyFor = ontModel.getObjectProperty(ORE + "proxyFor");
	proxyIn = ontModel.getObjectProperty(ORE + "proxyIn");
	isDescribedBy = ontModel.getObjectProperty(ORE + "isDescribedBy");

	checkNotNull(aggregation, aggregates, proxyFor, proxyIn, isDescribedBy);

	ore = ontModel;
}
 
开发者ID:apache,项目名称:incubator-taverna-language,代码行数:17,代码来源:RDFToManifest.java

示例15: loadPAV

import org.apache.jena.ontology.OntModel; //导入依赖的package包/类
protected synchronized void loadPAV() {
	if (pav != null)
		return;

	OntModel ontModel = loadOntologyFromClasspath(PAV_RDF, PAV);
	// properties from foaf
	createdBy = ontModel.getObjectProperty(PAV + "createdBy");
	createdOn = ontModel.getDatatypeProperty(PAV + "createdOn");
	authoredBy = ontModel.getObjectProperty(PAV + "authoredBy");
	authoredOn = ontModel.getDatatypeProperty(PAV + "authoredOn");
	retrievedFrom = ontModel.getObjectProperty(PAV + "retrievedFrom");
	retrievedBy = ontModel.getObjectProperty(PAV + "retrievedBy");
	retrievedOn = ontModel.getDatatypeProperty(PAV + "retrievedOn");

	checkNotNull(createdBy, createdOn, authoredBy, authoredOn,
			retrievedFrom, retrievedBy, retrievedOn);

	pav = ontModel;
}
 
开发者ID:apache,项目名称:incubator-taverna-language,代码行数:20,代码来源:RDFToManifest.java


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