如何理解推理器ProgressMonitor的输出?

问题描述 投票:1回答:1

我是语义网络领域的新手,我正试图比较更多的推理器。这是我的代码。

   OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
    File file = new File(args[0]);
    OWLOntology ontology = manager.loadOntologyFromOntologyDocument(file);
    Set<OWLClass> classes = ontology.getClassesInSignature();


    String inferredFile = args[1];
    //test for correctly uploading ontology
    OWLDataFactory df = manager.getOWLDataFactory();     
    Reasoner jfact = Reasoner.JFACT;
    System.out.println(RunReasoner(jfact, df,ontology,manager,inferredFile));



}

//CREATE AN ENUM REASONER
public enum Reasoner{
    HERMIT, 
    PELLET, 
    KONCLUDE,
    JFACT,
    FACT,
    ELK

}   
    public static String RunReasoner(Reasoner reasoner, OWLDataFactory df, OWLOntology ontology,                                                         OWLOntologyManager manager, String inferredFile) throws OWLOntologyCreationException, FileNotFoundException, IOException, OWLOntologyStorageException {
    String esito = "";
    OWLReasoner reasoner_object = null;
    if(reasoner == Reasoner.HERMIT) {
        /****************HERMIT****************************************************************************************/

        OWLReasonerFactory rf = new ReasonerFactory();
        TimedConsoleProgressMonitor progressMonitor = new TimedConsoleProgressMonitor();
        Configuration configuration = new Configuration();
        configuration.reasonerProgressMonitor = progressMonitor;
        configuration.ignoreUnsupportedDatatypes = true;
        reasoner_object = rf.createReasoner(ontology, configuration);


    }
    else if(reasoner == Reasoner.KONCLUDE) {

        // configure the server end-point
        URL url = new URL("http://localhost:8080");
        OWLlinkHTTPXMLReasonerFactory factory = new OWLlinkHTTPXMLReasonerFactory();
        TimedConsoleProgressMonitor progressMonitor = new TimedConsoleProgressMonitor();
        //OWLlinkReasonerConfiguration conf = (OWLlinkReasonerConfiguration) new SimpleConfiguration(progressMonitor);
        reasoner_object = factory.createNonBufferingReasoner(ontology);

    }
    else if(reasoner == Reasoner.JFACT) {
        TimedConsoleProgressMonitor progressMonitor = new TimedConsoleProgressMonitor();
        OWLReasonerConfiguration conf = new SimpleConfiguration(progressMonitor);
        JFactFactory factory = new JFactFactory();          
        reasoner_object = factory.createNonBufferingReasoner(ontology,conf);
    }
    //      else if(reasoner == Reasoner.FACT) {
    //          TimedConsoleProgressMonitor progressMonitor = new TimedConsoleProgressMonitor();
    //          OWLReasonerConfiguration conf = new SimpleConfiguration(progressMonitor);
    //          FaCTPlusPlusReasonerFactory factory = new FaCTPlusPlusReasonerFactory();
    //          reasoner_object = factory.createNonBufferingReasoner(ontology,conf);
    //      }
    else if(reasoner == Reasoner.ELK) {
        TimedConsoleProgressMonitor progressMonitor = new TimedConsoleProgressMonitor();
        OWLReasonerConfiguration conf = new SimpleConfiguration(progressMonitor);
        ElkReasonerFactory factory = new ElkReasonerFactory();
        reasoner_object = factory.createNonBufferingReasoner(ontology,conf);
    }
    else if(reasoner == Reasoner.PELLET) {
        TimedConsoleProgressMonitor progressMonitor = new TimedConsoleProgressMonitor();
        OWLReasonerConfiguration conf = new SimpleConfiguration(progressMonitor);
        reasoner_object = OpenlletReasonerFactory.getInstance().createReasoner(ontology,conf);          
    }
    else{
        esito = "Reasoner non valido";
    }
     boolean consistencyCheck = reasoner_object.isConsistent();
            if (consistencyCheck) {
                reasoner_object.precomputeInferences(InferenceType.CLASS_HIERARCHY,
                    InferenceType.CLASS_ASSERTIONS, InferenceType.OBJECT_PROPERTY_HIERARCHY,
                    InferenceType.DATA_PROPERTY_HIERARCHY, InferenceType.OBJECT_PROPERTY_ASSERTIONS);
                List<InferredAxiomGenerator<? extends OWLAxiom>> generators = new ArrayList<>();
                generators.add(new InferredSubClassAxiomGenerator());
                generators.add(new InferredClassAssertionAxiomGenerator());
                generators.add(new InferredDataPropertyCharacteristicAxiomGenerator());
                generators.add(new InferredEquivalentClassAxiomGenerator());
                generators.add(new InferredEquivalentDataPropertiesAxiomGenerator());
                generators.add(new InferredEquivalentObjectPropertyAxiomGenerator());
                generators.add(new InferredInverseObjectPropertiesAxiomGenerator());
                generators.add(new InferredObjectPropertyCharacteristicAxiomGenerator());

                // NOTE: InferredPropertyAssertionGenerator significantly slows down
                // inference computation
                generators.add(new org.semanticweb.owlapi.util.InferredPropertyAssertionGenerator());

                generators.add(new InferredSubClassAxiomGenerator());
                generators.add(new InferredSubDataPropertyAxiomGenerator());
                generators.add(new InferredSubObjectPropertyAxiomGenerator());
                List<InferredIndividualAxiomGenerator<? extends OWLIndividualAxiom>> individualAxioms =
                    new ArrayList<>();
                generators.addAll(individualAxioms);

                generators.add(new InferredDisjointClassesAxiomGenerator());
                InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner_object, generators); //Generates an ontology based on inferred axioms which are essentially supplied by a reasoner

                OWLOntology inferredAxiomsOntology = manager.createOntology();
                iog.fillOntology(df, inferredAxiomsOntology);
                System.out.println(inferredAxiomsOntology.getAxiomCount());
    //                  for(InferredAxiomGenerator<?> i : iog.getAxiomGenerators()) {
    //                      System.out.println(i);}
                File inferredOntologyFile = new File(inferredFile);
                // Now we create a stream since the ontology manager can then write to that stream.
                try (OutputStream outputStream = new FileOutputStream(inferredOntologyFile)) {
                    // We use the same format as for the input ontology.
                    manager.saveOntology(inferredAxiomsOntology, outputStream);
                }
                esito = "done "+ reasoner.toString();
                reasoner_object.dispose();
            } // End if consistencyCheck
            else {
                esito = reasoner.toString() +" -- Inconsistent input Ontology, Please check the OWL File";
            }
    return esito;
}     

我的输出是这样的:

Loading ...
    busy ...
    ... finished in 3484.5453
Classifying ...
    1%  73
    2%  56...

谁能给我解释一下这意味着什么? 有没有一些关于进度监控器输出的文档? 第二个问题:如何才能得到推理类词的数量?谢谢你的帮助,Rita

java semantic-web owl-api reasoner
1个回答
1
投票

该类的Javadoc可在线获取,并作为该类源代码的一部分。http:/owlcs.github.ioowlapiapidocs_5orgsemanticwebowlapireasonerTimedConsoleProgressMonitor.html。

增量的百分比取决于推理器的实现(这里可能有不可靠的地方,因为推理器只是有根据地猜测已经完成的工作量与仍需完成的工作量。这个数字是自上一次百分比增量以来所经过的毫秒。

推断的公理并不是全部计算出来的,而是在需要的时候才懒得评估,所以不能轻易计算。如果你想把推理具体化,可以找InferredAxiomGenerator。http:/owlcs.github.ioowlapiapidocs_5index.html?orgsemanticwebowlapireasonerpackage-summary.html。 的可能性。

© www.soinside.com 2019 - 2024. All rights reserved.