本文整理汇总了Java中org.semanticweb.owlapi.reasoner.OWLReasoner.flush方法的典型用法代码示例。如果您正苦于以下问题:Java OWLReasoner.flush方法的具体用法?Java OWLReasoner.flush怎么用?Java OWLReasoner.flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.semanticweb.owlapi.reasoner.OWLReasoner
的用法示例。
在下文中一共展示了OWLReasoner.flush方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isEdgeEntailed
import org.semanticweb.owlapi.reasoner.OWLReasoner; //导入方法依赖的package包/类
public boolean isEdgeEntailed(OWLEdge e, OWLOntology currentOntology, OWLReasoner reasoner) {
OWLOntologyManager m = getManager();
Set<OWLSubClassOfAxiom> scas = currentOntology.getSubClassAxiomsForSubClass(e.c);
Set<OWLSubClassOfAxiom> rmAxioms = new HashSet<OWLSubClassOfAxiom>();
for (OWLSubClassOfAxiom sca : scas) {
if (sca.getSuperClass().equals(e.p)) {
LOG.info("REMOVING: "+sca);
rmAxioms.add(sca);
}
}
boolean isEdgeAsserted = rmAxioms.size() > 0;
if (isEdgeAsserted) {
m.removeAxioms(currentOntology, rmAxioms);
reasoner.flush();
}
boolean isEntailed;
isEntailed = reasoner.getSuperClasses(e.c, false).containsEntity(e.p);
if (isEdgeAsserted) {
m.addAxioms(currentOntology, rmAxioms);
reasoner.flush();
}
return isEntailed;
}
示例2: main
import org.semanticweb.owlapi.reasoner.OWLReasoner; //导入方法依赖的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();
}
示例3: testPValue
import org.semanticweb.owlapi.reasoner.OWLReasoner; //导入方法依赖的package包/类
@Test
public void testPValue() throws Exception {
ParserWrapper pw = new ParserWrapper();
sourceOntol = pw.parseOBO(getResource("sim/mp-subset-1.obo").getAbsolutePath());
g = new OWLGraphWrapper(sourceOntol);
parseAssociations(getResource("sim/mgi-gene2mp-subset-1.tbl"), g);
LOG.info("Initialize OwlSim ..");
OWLReasoner reasoner = new ElkReasonerFactory().createReasoner(sourceOntol);
reasoner.flush();
try {
owlsim = owlSimFactory.createOwlSim(sourceOntol);
owlsim.createElementAttributeMapFromOntology();
owlsim.computeSystemStats();
} catch (UnknownOWLClassException e) {
e.printStackTrace();
} finally {
reasoner.dispose();
}
// Source sourceOntol and g are used as background knowledge ...
OWLSimReferenceBasedStatistics refBasedStats = new OWLSimReferenceBasedStatistics(owlsim, sourceOntol, g);
IRI iri = IRI.create("http://purl.obolibrary.org/obo/MGI_101761");
String[] testClasses = new String[] {"MP:0002758", "MP:0002772", "MP:0005448", "MP:0003660"};
Set<OWLClass> testClassesSet = new HashSet<OWLClass>();
for (String testClass : testClasses) {
testClassesSet.add(this.getOBOClass(testClass));
}
PValue pValue = refBasedStats.getPValue(testClassesSet, iri);
LOG.info(pValue.getSimplePValue());
}
示例4: testFindCoAnnotationList
import org.semanticweb.owlapi.reasoner.OWLReasoner; //导入方法依赖的package包/类
@Test
public void testFindCoAnnotationList() throws Exception {
ParserWrapper pw = new ParserWrapper();
sourceOntol = pw.parseOWL(getResourceIRIString("sim/mp-subset-1.obo"));
g = new OWLGraphWrapper(sourceOntol);
parseAssociations(getResource("sim/mgi-gene2mp-subset-1.tbl"), g);
owlpp = new OWLPrettyPrinter(g);
// assume buffering
OWLReasoner reasoner = new ElkReasonerFactory().createReasoner(sourceOntol);
try {
createOwlSim();
//sos.setReasoner(reasoner);
LOG.info("Reasoner="+owlsim.getReasoner());
reasoner.flush();
owlsim.createElementAttributeMapFromOntology();
owlsim.populateFullCoannotationMatrix();
SimJSONEngine sj = new SimJSONEngine(g, owlsim);
List<OWLClass> allClasses = new ArrayList<OWLClass>();
allClasses.addAll(g.getAllOWLClasses());
Collections.shuffle(allClasses);
int limit = 5;
String jsonStr = sj.getCoAnnotationListForAttribute(g.getOWLClassByIdentifier("MP:0002082"),limit);
LOG.info("Dumping coannotations and scores for all annotated classes");
LOG.info("EXAMPLE:"+jsonStr);
}
finally {
reasoner.dispose();
}
}
示例5: testGetEntropy
import org.semanticweb.owlapi.reasoner.OWLReasoner; //导入方法依赖的package包/类
@Test
public void testGetEntropy() throws OWLOntologyCreationException, IOException, OBOFormatParserException, UnknownOWLClassException {
ParserWrapper pw = new ParserWrapper();
sourceOntol = pw.parseOBO(getResourceIRIString("sim/mp-subset-1.obo"));
g = new OWLGraphWrapper(sourceOntol);
parseAssociations(getResource("sim/mgi-gene2mp-subset-1.tbl"), g);
owlpp = new OWLPrettyPrinter(g);
// assume buffering
OWLReasoner reasoner = new ElkReasonerFactory().createReasoner(sourceOntol);
try {
owlsim = new SimpleOwlSim(sourceOntol);
((SimpleOwlSim) owlsim).setReasoner(reasoner);
reasoner.flush();
Double e = owlsim.getEntropy();
LOG.info("ENTROPY OF ONTOLOGY = "+e);
for (String subset : g.getAllUsedSubsets()) {
LOG.info("SUBSET:"+subset);
e = owlsim.getEntropy(g.getOWLClassesInSubset(subset));
LOG.info(" ENTROPY OF "+subset+" = "+e);
}
}
finally {
reasoner.dispose();
}
}
示例6: coAnnotatedTest
import org.semanticweb.owlapi.reasoner.OWLReasoner; //导入方法依赖的package包/类
/**
* Test fetching commonly co-annotated classes in a set of individuals
* vs the background (entire) corpus using the TF-IDF method.
* @throws Exception
* @throws MathException
*/
@Test
public void coAnnotatedTest() throws Exception, MathException {
ParserWrapper pw = new ParserWrapper();
sourceOntol = pw.parseOWL(getResourceIRIString("sim/mp-subset-1.obo"));
g = new OWLGraphWrapper(sourceOntol);
parseAssociations(getResource("sim/mgi-gene2mp-subset-1.tbl"), g);
owlpp = new OWLPrettyPrinter(g);
// assume buffering
OWLReasoner reasoner = new ElkReasonerFactory().createReasoner(sourceOntol);
try {
this.createOwlSim();
owlsim.createElementAttributeMapFromOntology();
reasoner.flush();
owlsim.populateFullCoannotationMatrix();
Set<OWLNamedIndividual> inds = sourceOntol.getIndividualsInSignature();
for (OWLNamedIndividual i : inds) {
//get a random set of other individuals to do the subset
List<ClassCount> coaClasses = owlsim.getCoAnnotatedClassesForIndividual(i);
LOG.info("Found "+coaClasses.size()+" coannotated classes for "+g.getIdentifier(i));
for (ClassCount cc : coaClasses) {
LOG.info(owlpp.render(cc.c)+cc.score);
}
}
}
finally {
reasoner.dispose();
}
}
示例7: testGetCoannotatedClassesForAttribute
import org.semanticweb.owlapi.reasoner.OWLReasoner; //导入方法依赖的package包/类
/**
* Test fetching commonly co-annotated classes in the entire corpus, which
* uses the TF-IDF method.
* @throws Exception
*/
@Test
public void testGetCoannotatedClassesForAttribute() throws Exception {
ParserWrapper pw = new ParserWrapper();
sourceOntol = pw.parseOWL(getResourceIRIString("sim/mp-subset-1.obo"));
g = new OWLGraphWrapper(sourceOntol);
parseAssociations(getResource("sim/mgi-gene2mp-subset-1.tbl"), g);
owlpp = new OWLPrettyPrinter(g);
// assume buffering
OWLReasoner reasoner = new ElkReasonerFactory().createReasoner(sourceOntol);
try {
this.createOwlSim();
owlsim.createElementAttributeMapFromOntology();
reasoner.flush();
owlsim.populateFullCoannotationMatrix();
Set<OWLNamedIndividual> inds = sourceOntol.getIndividualsInSignature();
Set<OWLClass> cs = owlsim.getAllAttributeClasses();
LOG.info("Dumping coannotations and scores for all annotated classes");
for (OWLClass c : cs) {
List<ClassCount> lcc = owlsim.getCoannotatedClassesForAttribute(c,inds.size());
for (ClassCount cc : lcc) {
LOG.info(owlpp.render(c)+owlpp.render(cc.c)+cc.score);
}
}
}
finally {
reasoner.dispose();
}
}
示例8: testScores
import org.semanticweb.owlapi.reasoner.OWLReasoner; //导入方法依赖的package包/类
@Test
public void testScores() throws OWLOntologyCreationException, IOException, UnknownOWLClassException, OBOFormatParserException {
ParserWrapper pw = new ParserWrapper();
sourceOntol = pw.parseOBO(getResource("sim/mp-subset-1.obo").getAbsolutePath());
g = new OWLGraphWrapper(sourceOntol);
parseAssociations(getResource("sim/mgi-gene2mp-subset-1.tbl"), g);
owlpp = new OWLPrettyPrinter(g);
final int truncLen = 200;
// assume buffering
OWLReasoner reasoner = new ElkReasonerFactory().createReasoner(sourceOntol);
try {
createOwlSim();
//sos.setReasoner(reasoner);
LOG.info("Reasoner="+owlsim.getReasoner());
SimJSONEngine sj = new SimJSONEngine(g, owlsim);
//sos.saveOntology("/tmp/z.owl");
reasoner.flush();
owlsim.createElementAttributeMapFromOntology();
//owlsim.computeSystemStats();
for (OWLNamedIndividual i : sourceOntol.getIndividualsInSignature()) {
String jsonStr = sj.getAnnotationSufficiencyScore(i);
LOG.info("ANNOTSUFFICIENCY:"+jsonStr);
}
}
finally {
reasoner.dispose();
}
}
示例9: testPhenoSimMouse
import org.semanticweb.owlapi.reasoner.OWLReasoner; //导入方法依赖的package包/类
@Test
public void testPhenoSimMouse() throws IOException, OWLOntologyCreationException, OWLOntologyStorageException, MathException {
ParserWrapper pw = new ParserWrapper();
sourceOntol = pw.parseOWL(getResourceIRIString("test_phenotype.owl"));
g = new OWLGraphWrapper(sourceOntol);
owlpp = new OWLPrettyPrinter(g);
// assume buffering
OWLReasoner reasoner = new ElkReasonerFactory().createReasoner(sourceOntol);
try {
pproc = new PhenoSimHQEPreProcessor();
pproc.setInputOntology(sourceOntol);
pproc.setOutputOntology(sourceOntol);
pproc.setReasoner(reasoner);
pproc.setOWLPrettyPrinter(owlpp);
((PhenoSimHQEPreProcessor)pproc).defaultLCSElementFrequencyThreshold = 0.7;
//sos.setSimPreProcessor(pproc);
//sos.preprocess();
pproc.preprocess();
reasoner.flush();
sos = new SimpleOwlSim(sourceOntol);
sos.setSimPreProcessor(pproc);
sos.createElementAttributeMapFromOntology();
//sos.saveOntology("/tmp/z.owl");
reasoner.flush();
for (OWLNamedIndividual i : sourceOntol.getIndividualsInSignature()) {
for (OWLNamedIndividual j : sourceOntol.getIndividualsInSignature()) {
showSim(i,j);
}
}
}
finally {
reasoner.dispose();
}
}
示例10: testBasicSim
import org.semanticweb.owlapi.reasoner.OWLReasoner; //导入方法依赖的package包/类
@Test
public void testBasicSim() throws IOException, OWLOntologyCreationException, OWLOntologyStorageException, MathException, UnknownOWLClassException {
ParserWrapper pw = new ParserWrapper();
sourceOntol = pw.parseOWL(getResourceIRIString("sim/mp-subset-1.obo"));
g = new OWLGraphWrapper(sourceOntol);
parseAssociations(getResource("sim/mgi-gene2mp-subset-1.tbl"), g);
owlpp = new OWLPrettyPrinter(g);
// assume buffering
OWLReasoner reasoner = new ElkReasonerFactory().createReasoner(sourceOntol);
try {
owlsim = new SimpleOwlSim(sourceOntol);
((SimpleOwlSim) owlsim).setReasoner(reasoner);
LOG.info("Reasoner="+owlsim.getReasoner());
//sos.saveOntology("/tmp/z.owl");
reasoner.flush();
for (OWLNamedIndividual i : sourceOntol.getIndividualsInSignature()) {
//System.out.println("COMPARING: "+i);
for (OWLNamedIndividual j : sourceOntol.getIndividualsInSignature()) {
showSimOld(i,j);
}
}
}
finally {
reasoner.dispose();
}
}
示例11: testStats
import org.semanticweb.owlapi.reasoner.OWLReasoner; //导入方法依赖的package包/类
@Test
public void testStats() throws IOException, OWLOntologyCreationException, MathException, UnknownOWLClassException, OBOFormatParserException {
ParserWrapper pw = new ParserWrapper();
sourceOntol = pw.parseOBO(getResource("sim/mp-subset-1.obo").getAbsolutePath());
g = new OWLGraphWrapper(sourceOntol);
parseAssociations(getResource("sim/mgi-gene2mp-subset-1.tbl"), g);
setOutput("target/basic-owlsim-test.out");
// assume buffering
OWLReasoner reasoner = new ElkReasonerFactory().createReasoner(sourceOntol);
try {
this.createOwlSim();
owlsim.createElementAttributeMapFromOntology();
reasoner.flush();
owlsim.computeSystemStats();
LOG.info("Overall statistical summary for Test:");
LOG.info(owlsim.getSystemStats().toString());
LOG.info("Averaged statistical summary for Individuals in Test:");
// LOG.info(owlsim.getSummaryStatistics(Stat.MEAN).toString());
LOG.info("individuals: "+owlsim.getSummaryStatistics().n.getN());
LOG.info("mean(n/indiv): "+String.format("%1$.5f", owlsim.getSummaryStatistics().n.getMean()));
LOG.info("mean(meanIC): "+String.format("%1$.5f", owlsim.getSummaryStatistics().mean.getMean()));
LOG.info("mean(maxIC): "+String.format("%1$.5f", owlsim.getSummaryStatistics().max.getMean()));
LOG.info("max(maxIC): "+String.format("%1$.5f", owlsim.getSummaryStatistics().max.getMax()));
LOG.info("mean(sumIC): "+String.format("%1$.5f", owlsim.getSummaryStatistics().max.getMean()));
}
finally {
reasoner.dispose();
}
}
示例12: testIxI
import org.semanticweb.owlapi.reasoner.OWLReasoner; //导入方法依赖的package包/类
@Test
public void testIxI() throws Exception {
ParserWrapper pw = new ParserWrapper();
sourceOntol = pw.parseOBO(getResource("sim/mp-subset-1.obo").getAbsolutePath());
g = new OWLGraphWrapper(sourceOntol);
parseAssociations(getResource("sim/mgi-gene2mp-subset-1.tbl"), g);
setOutput("target/basic-owlsim-test.out");
// assume buffering
OWLReasoner reasoner = new ElkReasonerFactory().createReasoner(sourceOntol);
try {
this.createOwlSim();
owlsim.createElementAttributeMapFromOntology();
reasoner.flush();
owlsim.computeSystemStats();
owlsim.calculateMetricStats(owlsim.getAllElements(),owlsim.getAllElements());
String[] metrics = {"bmaAsymIC","bmaSymIC","bmaInverseAsymIC", "combinedScore", "simJ", "simGIC","maxIC"};
for (String m : metrics) {
LOG.info("Test Summary(mean) for "+m+": "+owlsim.getMetricStats(Stat.MEAN).get(m).getSummary());
LOG.info("Test Summary(min) for "+m+": "+owlsim.getMetricStats(Stat.MIN).get(m).getSummary());
LOG.info("Test Summary(max) for "+m+": "+owlsim.getMetricStats(Stat.MAX).get(m).getSummary());
}
} finally {
reasoner.dispose();
}
}
示例13: testInfoProfile
import org.semanticweb.owlapi.reasoner.OWLReasoner; //导入方法依赖的package包/类
@Test
public void testInfoProfile() throws OWLOntologyCreationException, IOException, UnknownOWLClassException, OBOFormatParserException {
ParserWrapper pw = new ParserWrapper();
sourceOntol = pw.parseOBO(getResource("sim/mp-subset-1.obo").getAbsolutePath());
g = new OWLGraphWrapper(sourceOntol);
parseAssociations(getResource("sim/mgi-gene2mp-subset-1.tbl"), g);
owlpp = new OWLPrettyPrinter(g);
final int truncLen = 200;
// assume buffering
OWLReasoner reasoner = new ElkReasonerFactory().createReasoner(sourceOntol);
try {
createOwlSim();
//sos.setReasoner(reasoner);
LOG.info("Reasoner="+owlsim.getReasoner());
SimJSONEngine sj = new SimJSONEngine(g, owlsim);
//sos.saveOntology("/tmp/z.owl");
reasoner.flush();
owlsim.createElementAttributeMapFromOntology();
owlsim.computeSystemStats();
for (OWLNamedIndividual i : sourceOntol.getIndividualsInSignature()) {
String jsonStr = sj.getAttributeInformationProfile(owlsim.getAttributesForElement(i));
LOG.info("InformationInfo:"+jsonStr);
}
}
finally {
reasoner.dispose();
}
}
示例14: testBasicSim
import org.semanticweb.owlapi.reasoner.OWLReasoner; //导入方法依赖的package包/类
@Test
public void testBasicSim() throws Exception {
ParserWrapper pw = new ParserWrapper();
sourceOntol = pw.parseOWL(getResourceIRIString("sim/mp-subset-1.obo"));
g = new OWLGraphWrapper(sourceOntol);
parseAssociations(getResource("sim/mgi-gene2mp-subset-1.tbl"), g);
setOutput("target/find-matches-test.out");
owlpp = new OWLPrettyPrinter(g);
// assume buffering
OWLReasoner reasoner = new ElkReasonerFactory().createReasoner(sourceOntol);
try {
this.createOwlSim();
owlsim.createElementAttributeMapFromOntology();
//sos.saveOntology("/tmp/z.owl");
reasoner.flush();
for (OWLNamedIndividual i : sourceOntol.getIndividualsInSignature()) {
renderer.getResultOutStream().println("\nI = "+i);
List<ElementPairScores> scoreSets = owlsim.findMatches(i, "MGI");
int rank = 1;
for (ElementPairScores s : scoreSets) {
renderer.getResultOutStream().println("\n RANK = "+rank);
renderer.printPairScores(s);
rank++;
}
}
}
finally {
reasoner.dispose();
}
}
示例15: testSearch
import org.semanticweb.owlapi.reasoner.OWLReasoner; //导入方法依赖的package包/类
@Test
public void testSearch() throws Exception {
ParserWrapper pw = new ParserWrapper();
sourceOntol = pw.parseOBO(getResource("sim/mp-subset-1.obo").getAbsolutePath());
g = new OWLGraphWrapper(sourceOntol);
parseAssociations(getResource("sim/mgi-gene2mp-subset-1.tbl"), g);
owlpp = new OWLPrettyPrinter(g);
final int truncLen = 200;
// assume buffering
OWLReasoner reasoner = new ElkReasonerFactory().createReasoner(sourceOntol);
try {
createOwlSim();
//sos.setReasoner(reasoner);
LOG.info("Reasoner="+owlsim.getReasoner());
SimJSONEngine sj = new SimJSONEngine(g, owlsim);
//sos.saveOntology("/tmp/z.owl");
reasoner.flush();
owlsim.createElementAttributeMapFromOntology();
owlsim.computeSystemStats();
for (OWLNamedIndividual i : sourceOntol.getIndividualsInSignature()) {
Set<OWLClass> atts = owlsim.getAttributesForElement(i);
String jsonStr = sj.search(atts, "MGI", true, false);
LOG.info(jsonStr);
}
}
finally {
reasoner.dispose();
}
}