【问题标题】:Save Pellet inferences using OWL API使用 OWL API 保存 Pellet 推理
【发布时间】:2015-07-30 14:38:43
【问题描述】:

我正在使用带有 OWL API 的最新版本的颗粒推理器:

 OWLOntologyManager manager=OWLManager.createOWLOntologyManager();
 OWLOntology fist_ontology=manager.loadOntologyFromOntologyDocument.........
 ................
 OWLOntology last_ontology=manager.loadOntologyFromOntologyDocument..........

 reasoner=PelletReasonerFactory.getInstance().createReasoner(last_ontology);
 manager.addOntologyChangeListener(reasoner);

管理器加载了几个本体。现在,我需要将 Pellet 对管理器加载的所有本体所做的所有推论保存在一个文件中,但我找不到任何示例。有人可以帮助我吗?谢谢!

【问题讨论】:

    标签: owl owl-api pellet


    【解决方案1】:

    我已经解决了:

    List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<>();
             gens.add(new InferredSubClassAxiomGenerator());  
             gens.add(new InferredClassAssertionAxiomGenerator());
             gens.add( new InferredDisjointClassesAxiomGenerator());
             gens.add( new InferredEquivalentClassAxiomGenerator());
             gens.add( new InferredEquivalentDataPropertiesAxiomGenerator());
             gens.add( new InferredEquivalentObjectPropertyAxiomGenerator());
             gens.add( new InferredInverseObjectPropertiesAxiomGenerator());
             gens.add( new InferredObjectPropertyCharacteristicAxiomGenerator());
             gens.add( new InferredPropertyAssertionGenerator());
             gens.add( new InferredSubDataPropertyAxiomGenerator());
             gens.add( new InferredSubObjectPropertyAxiomGenerator());
    
             InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, gens);
             OWLOntology infOnt = manager.createOntology();
             iog.fillOntology(datafactory, infOnt);
             manager.saveOntology(infOnt,new RDFXMLDocumentFormat(),IRI.create(new File("D://file.owl"))); 
    

    【讨论】:

      【解决方案2】:
      public void flushToFile() {
              reasoner.flush();
              //System.out.println(reasoner.isEntailed(ax5));
              InferredOntologyGenerator gen = new InferredOntologyGenerator(reasoner);
              gen.fillOntology(factory, newOntology);
              try {
                  manager.saveOntology(newOntology, new FileOutputStream(new File("D:\\XYZ\\OutputNew.owl")));
              } catch (OWLOntologyStorageException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              } catch (FileNotFoundException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
          }
      

      您可以使用此 api 将本体保存到文件中。另外,为了您对工作的详细了解,您可以通过此链接:- tells about the working of a pellet reasoner and swrl rules

      【讨论】:

      • 如果您不指定应该包含在本体中的推理类型,则只会添加基本推理。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多