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


Java OWLManager类代码示例

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


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

示例1: export

import org.semanticweb.owlapi.apibinding.OWLManager; //导入依赖的package包/类
@UITopiaVariant(
  author = "onprom team",
  affiliation = "Free University of Bozen-Bolzano",
  email = "[email protected]",
  website = "http://onprom.inf.unibz.it"
)
@PluginVariant(requiredParameterLabels = {0, 1})
public void export(PluginContext context, OWLOntology ontology, File file) {
  try {
    //default format is RDF/XML format for the ontology
    RDFDocumentFormat format = new RDFXMLDocumentFormat();
    //save the given ontology using the format to the file
    OWLManager.createOWLOntologyManager().saveOntology(ontology, format, new FileOutputStream(file));
    context.log("Exported ontology to the file: " + file.getName());
  } catch (Exception e) {
    context.log("Couldn't export ontology to the file: " + file.getName() + " ->" + e.getMessage());
  }
}
 
开发者ID:onprom,项目名称:onprom,代码行数:19,代码来源:OWLOntologyExportPlugin.java

示例2: importFromStream

import org.semanticweb.owlapi.apibinding.OWLManager; //导入依赖的package包/类
@UITopiaVariant(
  author = "onprom team",
  affiliation = "Free University of Bozen-Bolzano",
  email = "[email protected]",
  website = "http://onprom.inf.unibz.it"
)
@Override
protected OWLOntology importFromStream(final PluginContext context, final InputStream input, final String filename,
                                       final long fileSizeInBytes) {
  try {
    context.getFutureResult(0).setLabel("OWL ontology imported from " + filename);
    return OWLManager.createOWLOntologyManager().loadOntologyFromOntologyDocument(input);
  } catch (final Throwable e) {
    context.log("Couldn't import ontology:" + e.getMessage(), Logger.MessageLevel.ERROR);
  }
  return null;
}
 
开发者ID:onprom,项目名称:onprom,代码行数:18,代码来源:OWLOntologyImportPlugin.java

示例3: fromOntology

import org.semanticweb.owlapi.apibinding.OWLManager; //导入依赖的package包/类
/**
 * Returns a list of rules extracted from the given OWL-2 ontology document.
 * 
 * @param src an ontology document
 * @return a list of rules
 */
public static List<Rule> fromOntology(OWLOntologyDocumentSource src) {
	try {
		// use OWL-API to get a OWLOntology document from source
		OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
		manager.loadOntologyFromOntologyDocument(src);
		Set<OWLOntology> ontologies = manager.getOntologies();
		if (ontologies.isEmpty()) {
			return Collections.EMPTY_LIST;
		} else {
			// use first ontology from given source
			return fromOntology(ontologies.iterator().next());
		}
	} catch (OWLOntologyCreationException ex) {
		throw new IllegalArgumentException(
				"Loading ontology stream failed", ex);
	}
}
 
开发者ID:lszeremeta,项目名称:neo4j-sparql-extension-yars,代码行数:24,代码来源:Rules.java

示例4: createSmokeFilter

import org.semanticweb.owlapi.apibinding.OWLManager; //导入依赖的package包/类
private static OWLEquivalentClassesAxiom createSmokeFilter() {
    OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
    OWLDataFactory factory = manager.getOWLDataFactory();
    OWLClass owlFilter = factory.getOWLClass(ONT_IRI + "SmokeFilter");
    //hasContext some (observedProperty some Somke)
    OWLObjectProperty hasContextProp = factory.getOWLObjectProperty(ONT_SSNIOT_IRI + "hasContext");
    OWLObjectProperty observedProperty = factory.getOWLObjectProperty(ONT_SSN_IRI + "observedProperty");
    OWLClass propCls = factory.getOWLClass(ONT_IRI + "Smoke");


    return factory.getOWLEquivalentClassesAxiom(
            owlFilter,
            factory.getOWLObjectSomeValuesFrom(
                    hasContextProp,
                    factory.getOWLObjectSomeValuesFrom(observedProperty, propCls)
            )
    );
}
 
开发者ID:IBCNServices,项目名称:OBEP,代码行数:19,代码来源:Test.java

示例5: createTempFilter

import org.semanticweb.owlapi.apibinding.OWLManager; //导入依赖的package包/类
private static OWLEquivalentClassesAxiom createTempFilter() {
    OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
    OWLDataFactory factory = manager.getOWLDataFactory();

    OWLClass owlFilter = factory.getOWLClass(ONT_SSNIOT_IRI + "TemperatureFilter");

    OWLObjectProperty hasContextProp = factory.getOWLObjectProperty(ONT_SSNIOT_IRI + "hasContext");
    OWLObjectProperty observedProperty = factory.getOWLObjectProperty(ONT_SSN_IRI + "observedProperty");
    OWLClass propCls = factory.getOWLClass(ONT_SSNIOT_IRI + "Temperature");

    return factory.getOWLEquivalentClassesAxiom(
            owlFilter,
            factory.getOWLObjectSomeValuesFrom(
                    hasContextProp,
                    factory.getOWLObjectSomeValuesFrom(observedProperty, propCls)
            )
    );
}
 
开发者ID:IBCNServices,项目名称:OBEP,代码行数:19,代码来源:OBEPQueryAbstracterTest.java

示例6: createSmokeFilter

import org.semanticweb.owlapi.apibinding.OWLManager; //导入依赖的package包/类
private static OWLEquivalentClassesAxiom createSmokeFilter() {
    OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
    OWLDataFactory factory = manager.getOWLDataFactory();

    OWLClass owlFilter = factory.getOWLClass(ONT_SSNIOT_IRI + "SmokeFilter");

    OWLObjectProperty hasContextProp = factory.getOWLObjectProperty(ONT_SSNIOT_IRI + "hasContext");
    OWLObjectProperty observedProperty = factory.getOWLObjectProperty(ONT_SSN_IRI + "observedProperty");
    OWLClass propCls = factory.getOWLClass(ONT_SSNIOT_IRI + "Smoke");

    return factory.getOWLEquivalentClassesAxiom(
            owlFilter,
            factory.getOWLObjectSomeValuesFrom(
                    hasContextProp,
                    factory.getOWLObjectSomeValuesFrom(observedProperty, propCls)
            )
    );
}
 
开发者ID:IBCNServices,项目名称:OBEP,代码行数:19,代码来源:OBEPQueryAbstracterTest.java

示例7: getOntologyFromName

import org.semanticweb.owlapi.apibinding.OWLManager; //导入依赖的package包/类
/**
 * Open the OWL ontology (from the ontology resources of CartAGen) whose name
 * is passed as parameter.
 * @param name
 * @return
 * @throws OWLOntologyCreationException
 */
public static OWLOntology getOntologyFromName(String name)
    throws OWLOntologyCreationException {
  // create the URI from the name and the CartAGen ontologies folder path
  String uri = FOLDER_PATH + "/" + name + ".owl";
  InputStream stream = OwlUtil.class.getResourceAsStream(uri);
  File file = new File(stream.toString());
  String path = file.getAbsolutePath().substring(0,
      file.getAbsolutePath().lastIndexOf('\\'));
  path = path.replaceAll(new String("\\\\"), new String("//"));
  path = path + "//src/main//resources//ontologies//" + name + ".owl";
  // create the ontology from the URI using an OWLOntologyManager
  OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
  IRI physicalURI = IRI.create(new File(path));
  OWLOntology ontology = manager
      .loadOntologyFromOntologyDocument(physicalURI);

  return ontology;
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:26,代码来源:OwlUtil.java

示例8: getOntology

import org.semanticweb.owlapi.apibinding.OWLManager; //导入依赖的package包/类
/**
 * @param filename
 * @return
 */
private static OWLOntology getOntology(String filename) {
	File file = new File(filename);
	
	OWLOntologyManager m = OWLManager.createOWLOntologyManager();

	OWLOntology o;
	try {
		o = m.loadOntologyFromOntologyDocument(IRI.create(file.toURI()));
	} catch (OWLOntologyCreationException e) {
		fail("Cannot load ontology.");
		return null;
	}
	assertNotNull(o);

	return o;
}
 
开发者ID:AKSW,项目名称:Resource2Vec,代码行数:21,代码来源:R2VManager.java

示例9: oneTimeSetUp

import org.semanticweb.owlapi.apibinding.OWLManager; //导入依赖的package包/类
@BeforeClass
public static void oneTimeSetUp()
{
	try {
		// Create our ontology manager in the usual way.
		manager = OWLManager.createOWLOntologyManager();

		OWLOntology ont = manager.loadOntologyFromOntologyDocument(IRI.create("http://www.w3.org/TR/owl-guide/wine.rdf"));

		// We need to create an instance of Reasoner.
		StructuralReasonerFactory factory = new StructuralReasonerFactory();
		reasoner = factory.createReasoner(ont);
		reasoner.precomputeInferences();
       }
       catch(UnsupportedOperationException exception) {
           System.out.println("Unsupported reasoner operation.");
       }
       catch(OWLOntologyCreationException e) {
           System.out.println("Could not load the wine ontology: " + e.getMessage());
       }
}
 
开发者ID:protegeproject,项目名称:sparql-dl-api,代码行数:22,代码来源:QueryEngineStrictModeTest.java

示例10: testDataPropertyMetadata

import org.semanticweb.owlapi.apibinding.OWLManager; //导入依赖的package包/类
@Test
public void testDataPropertyMetadata() throws Exception {
	OWLOntologyManager m = OWLManager.createOWLOntologyManager();
	OWLOntology ontology = m.createOntology(IRI.generateDocumentIRI());
	{
		// create a test ontology with one data property
		OWLDataFactory f = m.getOWLDataFactory();
		IRI propIRI = IRI.generateDocumentIRI();
		OWLDataProperty prop = f.getOWLDataProperty(propIRI);
		m.addAxiom(ontology, f.getOWLDeclarationAxiom(prop));
		m.addAxiom(ontology, f.getOWLAnnotationAssertionAxiom(propIRI, f.getOWLAnnotation(f.getRDFSLabel(), f.getOWLLiteral("fake-data-property"))));
	}
	OWLGraphWrapper graph = new OWLGraphWrapper(ontology);
	MolecularModelManager<?> mmm = createM3(graph);
	Pair<List<JsonRelationInfo>,List<JsonRelationInfo>> pair = MolecularModelJsonRenderer.renderProperties(mmm, null, curieHandler);
	List<JsonRelationInfo> dataProperties = pair.getRight();
	assertEquals(1, dataProperties.size());
}
 
开发者ID:geneontology,项目名称:minerva,代码行数:19,代码来源:DataPropertyTest.java

示例11: main

import org.semanticweb.owlapi.apibinding.OWLManager; //导入依赖的package包/类
public static void main(String[] args) throws OWLOntologyCreationException {
    //register my built-in implementation
    BuiltInRegistry.instance.registerBuiltIn("urn:makub:builtIn#IRIparts", new CustomSWRLBuiltin(new IRIparts()));
    //initialize ontology and reasoner
    OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
    OWLOntology ontology = manager.loadOntologyFromOntologyDocument(IRI.create(DOC_URL));
    OWLReasonerFactory reasonerFactory = PelletReasonerFactory.getInstance();
    OWLReasoner reasoner = reasonerFactory.createReasoner(ontology, new SimpleConfiguration());
    OWLDataFactory factory = manager.getOWLDataFactory();
    PrefixDocumentFormat pm = manager.getOntologyFormat(ontology).asPrefixOWLOntologyFormat();
    //print the SWRL rule
    listSWRLRules(ontology);
    //use the rule with the built-in to infer property values
    OWLNamedIndividual martin = factory.getOWLNamedIndividual(":Martin", pm);
    listAllDataPropertyValues(martin, ontology, reasoner);
}
 
开发者ID:martin-kuba,项目名称:owl2-swrl-tutorial,代码行数:17,代码来源:IndividualSWRLBuiltinTutorial.java

示例12: getExplicitDLDisjointnessAxioms

import org.semanticweb.owlapi.apibinding.OWLManager; //导入依赖的package包/类
/**
 * A ^ B -> bottom
 * @param reasoner
 * @param ontology
 * @param cls
 * @author Shuo Zhang
 * @return
 */
public static OWLClassNodeSet getExplicitDLDisjointnessAxioms(OWLReasoner reasoner, OWLOntology ontology, OWLClass cls){
	
	OWLClassNodeSet nodeSet = new OWLClassNodeSet();
	
	OWLClassExpression subExp;
   	Set<OWLClassExpression> set;
       for (OWLSubClassOfAxiom sax : ontology.getSubClassAxiomsForSuperClass(OWLManager.getOWLDataFactory().getOWLNothing())) {
       	subExp = sax.getSubClass();
       	if (subExp instanceof OWLObjectIntersectionOf) {
       		set = subExp.asConjunctSet();
       		if (set.contains(cls) && set.size() == 2) {
       			for (OWLClassExpression op : set) {
       				if (!op.equals(cls) && !op.isAnonymous()) {
       					nodeSet.addNode(reasoner.getEquivalentClasses(op));
       					break;
       				}
       			}
       		}
       	}
       } 
	
       return nodeSet;
       
}
 
开发者ID:ernestojimenezruiz,项目名称:logmap-matcher,代码行数:33,代码来源:DisjointnessAxiomExtractor.java

示例13: ModuleExtractor

import org.semanticweb.owlapi.apibinding.OWLManager; //导入依赖的package包/类
/**
 * Default values for considerAnnotations=false, useIndexes=true, considerImportsClosure=true.
 * @param ontology Ontology to be modularized
 * @param dualConcepts Type of interpretation for concepts outside the signature
 * @param dualRoles Type of interpretation for properties outside the signature
 */
public ModuleExtractor(OWLOntology ontology, boolean dualConcepts, boolean dualRoles){
	
	ontologyManager = OWLManager.createOWLOntologyManager();
	//entity2Axioms = new MultiValueMap<OWLEntity, OWLAxiom>();
	ontologyAxioms=new HashSet<OWLAxiom>();
	moduleAxioms = new HashSet<OWLAxiom>();
	
	dataFactory = ontologyManager.getOWLDataFactory();
	
	collectedEntities=new HashSet<OWLEntity>();
	axiomSignatureCollector = new OWLEntityCollector(collectedEntities);
	
	//From axioms we do not want to collect data types
	axiomSignatureCollector.setCollectDatatypes(false);
	
	//Load Ontology/ies
	indexOntology(ontology);
	//System.out.println("Ontology Axioms: " + ontologyAxioms.size());
	
	//Set localityChecker
	setLocalityChecker(dualConcepts, dualRoles, false, true);
	
}
 
开发者ID:ernestojimenezruiz,项目名称:logmap-matcher,代码行数:30,代码来源:ModuleExtractor.java

示例14: getModuleFromAxioms

import org.semanticweb.owlapi.apibinding.OWLManager; //导入依赖的package包/类
/**
 * Necessary toi construct a module for an arbitriary set of axioms
 * @param moduleAxioms
 * @param moduleUri
 * @return
 */
public OWLOntology getModuleFromAxioms(Set<OWLAxiom> moduleAxioms, IRI moduleIri) {
	
	OWLOntologyManager ontologyManager = OWLManager.createOWLOntologyManager();
	
	OWLOntology module=null;
	
	try {
		module = ontologyManager.createOntology(moduleIri);
		List<OWLOntologyChange> ontoChanges = new ArrayList<OWLOntologyChange>();
		for(OWLAxiom axiom : moduleAxioms) {
			ontoChanges.add(new AddAxiom(module, axiom));
		}
		ontologyManager.applyChanges(ontoChanges);
	}
	
	catch(Exception e) {
		System.out.println("Error creating module ontology from extende set of axioms.");
		
	}

	//System.out.println("Time create OWLOntology for module (s): " + (double)((double)fin-(double)init)/1000.0);
	
	return module;
}
 
开发者ID:ernestojimenezruiz,项目名称:logmap-matcher,代码行数:31,代码来源:ModuleExtractorManager.java

示例15: checkEntailment

import org.semanticweb.owlapi.apibinding.OWLManager; //导入依赖的package包/类
/**
 * Classifies a given ontology and checks whether another ontology is
 * entailed by the former.
 *
 * @param premiseFile
 *            ontology file to be classified and used as premise
 * @param conclusionFile
 *            file with the conclusion
 * @throws FileNotFoundException
 *             if the file was not found
 * @throws OWLOntologyCreationException
 *             if the ontology could not be created
 * @throws OWLRendererException
 *             if a renderer error occurs
 * @return <code>true</code> if and only if the premise ontology entails the
 *         conclusion ontology
 */
public boolean checkEntailment(File premiseFile, File conclusionFile)
		throws OWLOntologyCreationException, OWLRendererException, FileNotFoundException {
	Objects.requireNonNull(premiseFile);
	Objects.requireNonNull(conclusionFile);
	logger.fine("starting jcel console ...");

	OWLOntologyManager manager = OWLManager.createOWLOntologyManager();

	logger.fine("loading premise ontology using the OWL API ...");
	OWLOntology premiseOntology = manager.loadOntologyFromOntologyDocument(premiseFile);

	logger.fine("loading conclusion ontology using the OWL API ...");
	OWLOntology conclusionOntology = manager.loadOntologyFromOntologyDocument(conclusionFile);

	logger.fine("starting reasoner ...");
	JcelReasoner reasoner = new JcelReasoner(premiseOntology, false);

	logger.fine("precomputing inferences ...");
	reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY);

	boolean ret = conclusionOntology.getAxioms().stream().allMatch(axiom -> reasoner.isEntailed(axiom));

	logger.fine("jcel console finished.");
	return ret;
}
 
开发者ID:julianmendez,项目名称:jcel,代码行数:43,代码来源:ConsoleStarter.java


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