Esempio n. 1
0
  public KuabaRepository createNewRepository(String url, File destination) {
    IRI iri;
    if (url == null) iri = IRI.generateDocumentIRI();
    else iri = IRI.create(url);

    try {
      OWLOntology inst = manager.createOntology(iri);
      OWLImportsDeclaration imp =
          manager.getOWLDataFactory().getOWLImportsDeclaration(IRI.create(ONTOLOGY_URL));
      AddImport addi = new AddImport(inst, imp);
      manager.applyChange(addi);
      KuabaRepository repo = new OwlApiKuabaRepository(inst, manager.getOWLDataFactory());
      repoMap.put(inst.getOntologyID().getOntologyIRI(), repo);
      fileMap.put(repo, destination);

      TemplateGenerator.generateRootQuestion(repo);

      if (destination != null) this.save(repo);
      return repo;
    } catch (OWLOntologyCreationException ex) {
      Logger.getLogger(OwlApiFileGateway.class.getName()).log(Level.SEVERE, null, ex);
    }

    return null;
  }
Esempio n. 2
0
 @SuppressWarnings({"unchecked", "rawtypes"})
 private OWLReasoner createModuleReasoner() throws OWLOntologyCreationException {
   LOG.info("Creating module reasoner for module: " + modelId);
   ModuleType mtype = ModuleType.BOT;
   OWLOntologyManager m =
       OWLManager.createOWLOntologyManager(
           aboxOntology.getOWLOntologyManager().getOWLDataFactory());
   SyntacticLocalityModuleExtractor sme =
       new SyntacticLocalityModuleExtractor(m, aboxOntology, mtype);
   Set<OWLEntity> seeds = (Set) aboxOntology.getIndividualsInSignature();
   OWLOntology module = sme.extractAsOntology(seeds, IRI.generateDocumentIRI());
   OWLReasoner reasoner = reasonerFactory.createReasoner(module);
   LOG.info("Done creating module reasoner module: " + modelId);
   return reasoner;
 }
Esempio n. 3
0
  private void setup() {
    try {
      ontology = ontologyManager.createOntology(IRI.generateDocumentIRI());
      hybridKB = new NoHRHybridKB(new File(System.getenv("XSB_BIN_DIRECTORY")), ontology, profile);
      parser = new NoHRRecursiveDescentParser(hybridKB.getVocabulary());
    } catch (final IPException e) {

      throw new RuntimeException(e);
    } catch (final OWLOntologyCreationException e) {

      throw new RuntimeException(e);
    } catch (final UnsupportedAxiomsException e) {

      throw new RuntimeException(e);
    } catch (final PrologEngineCreationException e) {
      throw new RuntimeException(e);
    }
  }
Esempio n. 4
0
  public KuabaRepository copy(KuabaRepository kr, String url, File destination) {
    IRI iri;
    if (url == null) iri = IRI.generateDocumentIRI();
    else iri = IRI.create(url);

    try {
      OWLOntology model = (OWLOntology) kr.getModel();
      OWLOntology inst = manager.createOntology(iri);

      OntologyMigrator migrator = new OntologyMigrator(manager, model, inst);
      migrator.performMigration();

      EntityFindAndReplaceURIRenamer renamer =
          new EntityFindAndReplaceURIRenamer(
              manager,
              inst.getSignature(false),
              Collections.singleton(inst),
              model.getOntologyID().getOntologyIRI().toString(),
              iri.toString());

      if (renamer.hasErrors()) System.err.println("ERRO durante a cópia - rename");

      manager.applyChanges(renamer.getChanges());

      KuabaRepository repo = new OwlApiKuabaRepository(inst, manager.getOWLDataFactory());
      repoMap.put(inst.getOntologyID().getOntologyIRI(), repo);
      fileMap.put(repo, destination);

      return repo;

    } catch (OWLOntologyCreationException ex) {
      System.err.println("ERRO em copy");
      Logger.getLogger(OwlApiFileGateway.class.getName()).log(Level.SEVERE, null, ex);
    }

    return null;
  }