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


Java OWLOntologyManager.loadOntologyFromOntologyDocument方法代碼示例

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


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

示例1: fromOntology

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的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

示例2: getOntologyFromName

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的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

示例3: getOntology

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的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

示例4: checkEntailment

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的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

示例5: EBDAReasonerImplWithParallelProcessing

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
/**
 * Initializes EBDA Reasoner based on the given EBDA Model.
 * 
 * @author Ario Santoso ([email protected] / [email protected])
 * @param ebdaModel
 */
public EBDAReasonerImplWithParallelProcessing(EBDAModelWithOptimizedXAttributesEncoding ebdaModel){

	this.xfact = XFactoryOnProm.getInstance();
	super.setExecutionLogListener(null);
	this.questFactory = new QuestOWLFactory();

	//Load the Event Ontology
		//System.out.println("\n--------------------------------------------------------");
		//System.out.println("DEBUGA: loading event ontology");
				
		OWLOntologyManager eventOntoMan = OWLManager.createOWLOntologyManager();
		URL eventOntoURL = this.getClass().getResource(XESEOConstants.eventOntoPath);

		//System.out.println("loading event ontology from: "+ this.eventOntoURL.getPath());
		
		try {
			eventOnto = eventOntoMan.loadOntologyFromOntologyDocument(eventOntoURL.openStream());
		} catch (OWLOntologyCreationException | IOException e) {
			e.printStackTrace();
		}

		//System.out.println("DEBUGA: END OF loading event ontology");
		//System.out.println("\n--------------------------------------------------------");
	//END OF Loading the Event Ontology

	this.questOWLDefaultConfig = this.createQuestOWLDefaultConfig(ebdaModel);
	this.disableLocalLogging();
}
 
開發者ID:onprom,項目名稱:onprom,代碼行數:35,代碼來源:EBDAReasonerImplWithParallelProcessing.java

示例6: setUp

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
    graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(new File(TEST_GRAPH_DB_PATH));
    OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
    OWLOntology ontology = manager.loadOntologyFromOntologyDocument(file.getFile());
    OWLDataFactory factory = manager.getOWLDataFactory();
    loader = new Owl2Neo4jLoader(graphDb, ontology, factory);
}
 
開發者ID:ISA-tools,項目名稱:FAIRsharing-Owl2Neo,代碼行數:9,代碼來源:Owl2Neo4jLoaderTest.java

示例7: StatisticalFunctionalityDetector

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
public StatisticalFunctionalityDetector(File ontologyFile, double threshold) {
	try {
		OWLOntologyManager man = OWLManager.createOWLOntologyManager();
		ontology = man.loadOntologyFromOntologyDocument(ontologyFile);
		dataFactory = man.getOWLDataFactory();
	} catch (OWLOntologyCreationException e) {
		e.printStackTrace();
	}
	this.threshold = threshold;
}
 
開發者ID:dice-group,項目名稱:BENGAL,代碼行數:11,代碼來源:StatisticalFunctionalityDetector.java

示例8: main

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
        startTime = System.currentTimeMillis();
        OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
        File testOntology = new File("/Users/alo/IdeaProjects/rf2-to-owl/sct.owl");
//        File testOntology = new File("/Users/alo/Downloads/conceptsOwlComplete-cd-alo.xml");
        System.out.println("testOntology: " + testOntology.getName());
        OWLOntology ontology = manager.loadOntologyFromOntologyDocument(testOntology);
        System.out.println("Terminology loaded in: " + (System.currentTimeMillis() - startTime) + " ms.");
        startTime = System.currentTimeMillis();
        PrintWriter writer2 = new PrintWriter("owlRefset-sct-owl.txt", "UTF-8");
        fr.render(ontology,writer2);
        writer2.close();
        System.out.println("OWL Refset created in: " + (System.currentTimeMillis() - startTime) + " ms.");
    }
 
開發者ID:termMed,項目名稱:rf2-to-owl,代碼行數:15,代碼來源:TestRenderer.java

示例9: setupRules

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
@BeforeClass
public static void setupRules() throws OWLOntologyCreationException {
	OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
	OWLOntology ont = manager.loadOntologyFromOntologyDocument(GPADSPARQLTest.class.getResourceAsStream("/ro-merged-2017-10-02.ofn"));
	Set<Rule> rules = new HashSet<>();
	rules.addAll(JavaConverters.setAsJavaSetConverter(OWLtoRules.translate(ont, Imports.INCLUDED, true, true, true, true)).asJava());
	rules.addAll(JavaConverters.setAsJavaSetConverter(OWLtoRules.indirectRules(ont)).asJava());
	arachne = new RuleEngine(Bridge.rulesFromJena(JavaConverters.asScalaSetConverter(rules).asScala()), true);
}
 
開發者ID:geneontology,項目名稱:minerva,代碼行數:10,代碼來源:GPADSPARQLTest.java

示例10: loadOWLOntologyDocumentSource

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
private static OWLOntology loadOWLOntologyDocumentSource(final OWLOntologyDocumentSource source, final OWLOntologyManager manager) throws OWLOntologyCreationException {
	final OWLOntology ontology;
	if (source instanceof RioMemoryTripleSource) {
		RioParserImpl parser = new RioParserImpl(new RioRDFXMLDocumentFormatFactory());
		ontology = manager.createOntology();
		try {
			parser.parse(source, ontology, new OWLOntologyLoaderConfiguration());
		} catch (IOException e) {
			throw new OWLOntologyCreationException(e);
		}
	} else {
		ontology = manager.loadOntologyFromOntologyDocument(source);
	}
	return ontology;
}
 
開發者ID:geneontology,項目名稱:minerva,代碼行數:16,代碼來源:CoreMolecularModelManager.java

示例11: main

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
/**
 * @param args
 * @throws OWLOntologyCreationException
 */
public static void main(String[] args) throws OWLOntologyCreationException {
	OWLOntologyManager man = OWLManager.createOWLOntologyManager();

	// Load your ontology.
	OWLOntology ont = man
			.loadOntologyFromOntologyDocument(new File(args[0]));
	
	// Create an ELK reasoner.
	OWLReasonerFactory reasonerFactory = new ElkReasonerFactory();
	OWLReasoner reasoner = reasonerFactory.createReasoner(ont);
	
	// Precompute instances for each named class in the ontology
	reasoner.precomputeInferences(InferenceType.CLASS_ASSERTIONS);

	// List representative instances for each class.
	for (OWLClass clazz : ont.getClassesInSignature()) {
		for (Node<OWLNamedIndividual> individual : reasoner.getInstances(
				clazz, true)) {
			System.out.println(clazz + "("
					+ individual.getRepresentativeElement() + ")");
		}
	}

	// Terminate the worker threads used by the reasoner.
	reasoner.dispose();
}
 
開發者ID:liveontologies,項目名稱:elk-reasoner,代碼行數:31,代碼來源:RetrievingInstances.java

示例12: main

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
public static void main(String[] args) throws OWLOntologyStorageException,
		OWLOntologyCreationException {
	OWLOntologyManager manager = OWLManager.createOWLOntologyManager();

	// Load your ontology
	OWLOntology ont = manager.loadOntologyFromOntologyDocument(new File("path-to-ontology"));

	// Create an ELK reasoner.
	OWLReasonerFactory reasonerFactory = new ElkReasonerFactory();
	OWLReasoner reasoner = reasonerFactory.createReasoner(ont);

	// Classify the ontology.
	reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY);

	OWLDataFactory factory = manager.getOWLDataFactory();
	OWLClass subClass = factory.getOWLClass(IRI.create("http://www.co-ode.org/ontologies/galen#AbsoluteShapeState"));
	OWLAxiom removed = factory.getOWLSubClassOfAxiom(subClass, factory.getOWLClass(IRI.create("http://www.co-ode.org/ontologies/galen#ShapeState")));
	
	OWLAxiom added = factory.getOWLSubClassOfAxiom(subClass, factory.getOWLClass(IRI.create("http://www.co-ode.org/ontologies/galen#GeneralisedStructure")));
	// Remove an existing axiom, add a new axiom
	manager.addAxiom(ont, added);
	manager.removeAxiom(ont, removed);
	// This is a buffering reasoner, so you need to flush the changes
	reasoner.flush();
	
	// Re-classify the ontology, the changes should be accommodated
	// incrementally (i.e. without re-inferring all subclass relationships)
	// You should be able to see it from the log output
	reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY);		
	
	// Terminate the worker threads used by the reasoner.
	reasoner.dispose();
}
 
開發者ID:liveontologies,項目名稱:elk-reasoner,代碼行數:34,代碼來源:IncrementalClassification.java

示例13: loadFromDisk

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
private OWLOntology loadFromDisk(String suffix) throws OWLOntologyCreationException {
	OWLOntologyManager changeManager = OWLManager.createOWLOntologyManager();
	
	for (File delta : deltaDir_.listFiles()) {
		if (delta.getName().endsWith(suffix)) {
			return changeManager.loadOntologyFromOntologyDocument(delta);
		}
	}
	
	return null;
}
 
開發者ID:liveontologies,項目名稱:elk-reasoner,代碼行數:12,代碼來源:OWLAPIIncrementalClassificationMultiDeltas.java

示例14: testGetLabels

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
@Test
public void testGetLabels() throws Exception {
	OWLOntologyManager m = OWLManager.createOWLOntologyManager();
	ont = m.loadOntologyFromOntologyDocument(getResource("caro.owl"));

	boolean allHaveLabels = true;
	for (OWLClass c : ont.getClassesInSignature()) {
		String label = getLabel(c);
		if (label == null)
			allHaveLabels = false;
		//System.out.println(c + " LABEL:" + label);
	}
	assertTrue(allHaveLabels);
}
 
開發者ID:owlcollab,項目名稱:owltools,代碼行數:15,代碼來源:GetLabelsTest.java

示例15: initWithInterrupts

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
@Override
public void initWithInterrupts() throws Exception {
	final InputStream input = getManifest().getInput().getUrl()
			.openStream();
	OWLOntologyManager manager = TestOWLManager.createOWLOntologyManager();
	OWLOntology ontology = manager.loadOntologyFromOntologyDocument(input);

	final Random random = new Random(RandomSeedProvider.VALUE);
	reasoner_ = OWLAPITestUtils.createReasoner(ontology, false,
			new TestReasonerInterrupter(new RandomInterruptMonitor(random,
					getInterruptionChance(),
					getInterruptionIntervalNanos())));
}
 
開發者ID:liveontologies,項目名稱:elk-reasoner,代碼行數:14,代碼來源:OwlApiReasoningTestDelegate.java


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