本文整理匯總了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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}
示例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.");
}
示例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);
}
示例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;
}
示例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();
}
示例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();
}
示例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;
}
示例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);
}
示例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())));
}