本文整理汇总了Java中org.semanticweb.owlapi.reasoner.OWLReasonerFactory类的典型用法代码示例。如果您正苦于以下问题:Java OWLReasonerFactory类的具体用法?Java OWLReasonerFactory怎么用?Java OWLReasonerFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OWLReasonerFactory类属于org.semanticweb.owlapi.reasoner包,在下文中一共展示了OWLReasonerFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: beforeClass
import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; //导入依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
// Setup environment.
ParserWrapper pw = new ParserWrapper();
//NOTE: Yes, the GO here is unnecessary, but we're trying to also catch a certain behavior
// where auxilery ontologies are not caught. The best wat to do that here is to load ECO
// second and then do the merge.
OWLOntology ont_main = pw.parse(getResourceIRIString("go_xp_predictor_test_subset.obo"));
OWLOntology ont_scnd = pw.parse(getResourceIRIString("eco.obo"));
g = new OWLGraphWrapper(ont_main);
g.addSupportOntology(ont_scnd);
// NOTE: This step is necessary or things will get ignored!
// (This cropped-up in the loader at one point.)
for (OWLOntology ont : g.getSupportOntologySet())
g.mergeOntology(ont);
OWLReasonerFactory reasonerFactory = new ElkReasonerFactory();
r = reasonerFactory.createReasoner(g.getSourceOntology());
g.setReasoner(r);
}
示例2: beforeClass
import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; //导入依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
// Setup environment.
ParserWrapper pw = new ParserWrapper();
//NOTE: Yes, the GO here is unnecessary, but we're trying to also catch a certain behavior
// where auxiliary ontologies are not caught. The best way to do that here is to load taxslim
// second and then do the merge.
OWLOntology ont_main = pw.parse(getResourceIRIString("go_xp_predictor_test_subset.obo"));
OWLOntology ont_scnd = pw.parse(getResourceIRIString("taxslim.obo"));
g = new OWLGraphWrapper(ont_main);
g.addSupportOntology(ont_scnd);
// NOTE: This step is necessary or things will get ignored!
// (This cropped-up in the loader at one point.)
for (OWLOntology ont : g.getSupportOntologySet())
g.mergeOntology(ont);
OWLReasonerFactory reasonerFactory = new ElkReasonerFactory();
r = reasonerFactory.createReasoner(g.getSourceOntology());
g.setReasoner(r);
}
示例3: createSubOntologyFromDLQuery
import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; //导入依赖的package包/类
/**
* Create a new sub ontology from a given DL query and source ontology. The
* subset will be created in the target ontology.
*
* @param namedQuery
* @param sourceGraph
* @param targetGraph
* @param reasonerFactory
* @param toMerge
*/
public void createSubOntologyFromDLQuery(OWLClass namedQuery,
OWLGraphWrapper sourceGraph, OWLGraphWrapper targetGraph,
OWLReasonerFactory reasonerFactory, Set<OWLOntology> toMerge)
{
try {
Set<OWLClass> subset = DLQueryTool.executeQuery(namedQuery, sourceGraph.getSourceOntology(), reasonerFactory);
if (subset.isEmpty()) {
return;
}
createSubSet(targetGraph, subset, toMerge);
} catch (OWLOntologyCreationException e) {
LOG.error("Could not create ontology.", e);
// TODO throw Exception?
return;
}
}
示例4: testSubsetterSpecies
import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; //导入依赖的package包/类
@Test
public void testSubsetterSpecies() throws Exception {
ParserWrapper p = new ParserWrapper();
p.setCheckOboDoc(false);
OWLOntology owlOntology = p.parse(getResourceIRIString("speciesMergeTest.obo"));
OWLGraphWrapper graph = new OWLGraphWrapper(owlOntology);
OWLReasonerFactory rf = new ElkReasonerFactory();
OWLReasoner reasoner = rf.createReasoner(graph.getSourceOntology());
SpeciesSubsetterUtil smu = new SpeciesSubsetterUtil(graph);
//smu.viewProperty = graph.getOWLObjectPropertyByIdentifier("BFO:0000050");
smu.taxClass = graph.getOWLClassByIdentifier("T:1");
smu.reasoner = reasoner;
smu.removeOtherSpecies();
p.saveOWL(smu.ont, new OBODocumentFormat(), "target/speciesSubset.obo");
//p.saveOWL(smu.ont, getResourceIRIString("target/speciesSubset.owl"));
assertNull(graph.getOWLClassByIdentifier("U:24"));
}
示例5: testMergeSpecies
import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; //导入依赖的package包/类
@Test
public void testMergeSpecies() throws Exception {
ParserWrapper p = new ParserWrapper();
OWLOntology owlOntology = p.parse(getResourceIRIString("speciesMergeTest.obo"));
OWLGraphWrapper graph = new OWLGraphWrapper(owlOntology);
OWLReasonerFactory rf = new ElkReasonerFactory();
OWLReasoner reasoner = rf.createReasoner(graph.getSourceOntology());
SpeciesMergeUtil smu = new SpeciesMergeUtil(graph);
smu.viewProperty = graph.getOWLObjectPropertyByIdentifier("BFO:0000050");
smu.taxClass = graph.getOWLClassByIdentifier("T:1");
smu.reasoner = reasoner;
smu.suffix = "coelocanth";
smu.merge();
p.saveOWL(smu.ont, new OBODocumentFormat(), "target/speciesMergeOut.obo");
}
示例6: main
import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; //导入依赖的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);
}
示例7: main
import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; //导入依赖的package包/类
public static void main(String[] args) throws OWLOntologyCreationException {
//register my built-in
BuiltInRegistry.instance.registerBuiltIn("urn:makub:builtIn#thisYear", new GeneralFunctionBuiltIn(new ThisYear()));
//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();
//use the rule with the built-in to infer data property values
OWLNamedIndividual martin = factory.getOWLNamedIndividual(":Martin", pm);
listAllDataPropertyValues(martin, ontology, reasoner);
OWLNamedIndividual ivan = factory.getOWLNamedIndividual(":Ivan", pm);
listAllDataPropertyValues(ivan, ontology, reasoner);
}
示例8: main
import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; //导入依赖的package包/类
/**
* @param args
*/
public static void main(String[] args) {
long start = System.currentTimeMillis();
OWLOntologyManager man = OWLManager.createOWLOntologyManager();
// loading the root ontology
OWLOntology root = null;
try {
root = man.loadOntologyFromOntologyDocument(new File(
"C:\\dev\\ontologies\\owl\\snomed_20130131_stated.owl"));
} catch (OWLOntologyCreationException e) {
e.printStackTrace();
return;
}
System.out.println("owl-api loading: "+(System.currentTimeMillis()-start));
// Create a Snorocket reasoner and classify
OWLReasonerFactory reasonerFactory = new SnorocketReasonerFactory();
OWLReasoner reasoner = reasonerFactory.createNonBufferingReasoner(root);
reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY);
reasoner.dispose();
System.out.println(Statistics.INSTANCE.getStatistics());
System.out.println("Total time: "+Statistics.INSTANCE.getTotalTime());
}
示例9: DLPPINotAnalyser
import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; //导入依赖的package包/类
public DLPPINotAnalyser(Bpmn20ModelHandlerInterface bpmnModelHandler, PpiNotModelHandlerInterface ppinotModelHandler, OWLReasonerFactory reasonerFactory) {
this.bpmnModelHandler = bpmnModelHandler;
this.ppinotModelHandler = ppinotModelHandler;
owlManager = OWLManager.createOWLOntologyManager();
conversor = new IdOwlConversor();
try {
BPMN2OWLConverterInterface bpmnConverter = new BPMN2OWLConverter(BPMN_BASE_IRI, owlManager);
bpmnOntology = bpmnConverter.convertToOwlOntology(bpmnModelHandler);
String bpmnOntologyURI = bpmnConverter.getOntologyURI();
PPINOT2OWLConverterInterface ppinotConverter = new PPINOT2OWLConverter(PPINOT_BASE_IRI, owlManager);
ppinotConverter.setBpmnData(bpmnOntologyURI, bpmnModelHandler);
ppinotOntology = ppinotConverter.convertToOwlOntology(ppinotModelHandler);
} catch (OWLOntologyCreationException e) {
throw new RuntimeException(e);
}
AnalysisOntologyBuilder builder = new AnalysisOntologyBuilder(owlManager);
String analysisURI = PPINOT_BASE_IRI + bpmnModelHandler.getProcId() + "-analysis.owl";
analysisOntology = builder.buildAnalysisOntology(analysisURI, ppinotOntology);
engine = new DLQueryEngine(reasonerFactory.createReasoner(analysisOntology));
}
示例10: StructuralRootDerivedReasoner
import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; //导入依赖的package包/类
public StructuralRootDerivedReasoner(OWLOntologyManager man, OWLReasoner reasoner, OWLReasonerFactory reasonerFactory) {
this.man = man;
this.reasonerFactory = reasonerFactory;
this.reasoner = reasoner;
this.child2Parent = new HashMap<OWLClass, Set<OWLClass>>();
this.parent2Child = new HashMap<OWLClass, Set<OWLClass>>();
roots = new HashSet<OWLClass>();
try {
getMergedOntology();
}
catch (ExplanationException e) {
e.printStackTrace();
}
dirty = true;
}
示例11: InferenceProviderCreatorImpl
import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; //导入依赖的package包/类
InferenceProviderCreatorImpl(OWLReasonerFactory rf, int maxConcurrent, boolean useSLME, String name) {
super();
this.rf = rf;
this.useSLME = useSLME;
this.name = name;
this.concurrentLock = new Semaphore(maxConcurrent);
}
示例12: main
import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; //导入依赖的package包/类
static public void main (String[] args) throws OWLException,
InstantiationException, IllegalAccessException,
ClassNotFoundException {
String reasonerFactoryClassName = null;
String pathToOwlOntology = "/Users/piek/Desktop/NWR/NWR-ontology/version-0.6/ESO_version_0.6.owl";
OWLOntologyManager m = (OWLOntologyManager) OWLManager.getOWLDataFactory();
@SuppressWarnings("null")
//@Nonnull
IRI documentIRI = IRI.create(pathToOwlOntology);
OWLOntology ontology = m
.loadOntologyFromOntologyDocument(documentIRI);
// Report information about the ontology
System.out.println("Ontology Loaded...");
System.out.println("Document IRI: " + documentIRI);
System.out.println("Ontology : " + ontology.getOntologyID());
System.out.println("Format : "
+ m.getOntologyFormat(ontology));
@SuppressWarnings("null")
OwlReader2 simpleHierarchy = new OwlReader2(
(OWLReasonerFactory) Class.forName(reasonerFactoryClassName)
.newInstance(), ontology);
// Get Thing
OWLClass clazz = m.getOWLDataFactory().getOWLThing();
System.out.println("Class : " + clazz);
// Print the hierarchy below thing
simpleHierarchy.printHierarchy(clazz);
}
示例13: BlackBoxExplanationExtractor
import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; //导入依赖的package包/类
public BlackBoxExplanationExtractor(
OWLOntology ontology,
OWLReasonerFactory reasonerFactory,
OWLReasoner reasoner,
int maxExplanations){
this(ontology, reasonerFactory, reasoner, Collections.EMPTY_SET, maxExplanations);
}
示例14: main
import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; //导入依赖的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();
}
示例15: main
import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; //导入依赖的package包/类
public static void main(String[] args) throws OWLOntologyStorageException,
OWLOntologyCreationException {
OWLOntologyManager inputOntologyManager = OWLManager.createOWLOntologyManager();
OWLOntologyManager outputOntologyManager = OWLManager.createOWLOntologyManager();
// Load your ontology.
OWLOntology ont = inputOntologyManager.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);
// To generate an inferred ontology we use implementations of
// inferred axiom generators
List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>();
gens.add(new InferredSubClassAxiomGenerator());
gens.add(new InferredEquivalentClassAxiomGenerator());
// Put the inferred axioms into a fresh empty ontology.
OWLOntology infOnt = outputOntologyManager.createOntology();
InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner,
gens);
iog.fillOntology(outputOntologyManager.getOWLDataFactory(), infOnt);
// Save the inferred ontology.
outputOntologyManager.saveOntology(infOnt,
new FunctionalSyntaxDocumentFormat(),
IRI.create((new File("path-to-output").toURI())));
// Terminate the worker threads used by the reasoner.
reasoner.dispose();
}