Package edu.isi.karma.modeling.ontology

Examples of edu.isi.karma.modeling.ontology.OntologyManager


  public static void main(String[] args) throws Exception {
   
    /** Check if any ontology needs to be preloaded **/
    String preloadedOntDir = "/Users/mohsen/karma/preloaded-ontologies/";
    File ontDir = new File(preloadedOntDir);
    OntologyManager mgr = null;
    if (ontDir.exists()) {
      File[] ontologies = ontDir.listFiles();
      mgr = new OntologyManager();
      for (File ontology: ontologies) {
        System.out.println(ontology.getName());
        if (ontology.getName().endsWith(".owl") ||
            ontology.getName().endsWith(".rdf") ||
            ontology.getName().endsWith(".n3") ||
            ontology.getName().endsWith(".ttl") ||
            ontology.getName().endsWith(".xml")) {
          logger.info("Loading ontology file: " + ontology.getAbsolutePath());
          try {
            String encoding = EncodingDetector.detect(ontology);
            mgr.doImport(ontology, encoding);
          } catch (Exception t) {
//            logger.error("Error loading ontology: " + ontology.getAbsolutePath(), t);
          }
        } else {
          logger.error ("the file: " + ontology.getAbsolutePath() + " does not have proper format: xml/rdf/n3/ttl/owl");
        }
      }
      // update the cache at the end when all files are added to the model
      mgr.updateCache();
    }
   
    GraphBuilderTopK gbtk = new GraphBuilderTopK(mgr, false);
   
    Node n1 = new InternalNode("n1", new Label("http://erlangen-crm.org/current/E55_Type"));
View Full Code Here


  }
 
  @Override
  public void setup(UpdateContainer uc) {
    logger.info("Start OntologyMetadata.setup");
    OntologyManager ontologyManager = workspace.getOntologyManager();
    /** Check if any ontology needs to be preloaded **/
    String preloadedOntDir = ServletContextParameterMap.getParameterValue(ServletContextParameterMap.ContextParameter.PRELOADED_ONTOLOGY_DIRECTORY);
    File ontDir = new File(preloadedOntDir);
    logger.info("Load ontologies from " + preloadedOntDir);
    if (ontDir.exists()) {
      File[] ontologies = ontDir.listFiles();
      for (File ontology: ontologies) {
        if(ontology.getName().startsWith(".") || ontology.isDirectory()) {
          continue; //Ignore . files
        }
        if (ontology.getName().endsWith(".owl") ||
            ontology.getName().endsWith(".rdf") ||
            ontology.getName().endsWith(".n3") ||
            ontology.getName().endsWith(".ttl") ||
            ontology.getName().endsWith(".xml")) {
          if(ontology.getName().matches("catalog\\-v[0-9]{3}\\.xml")) {
            logger.info("Ignore: " + ontology.getAbsolutePath());
            continue; //ignore mac catalog-v001.xml file
          }
          logger.info("Loading ontology file: " + ontology.getAbsolutePath());
          try {
            String encoding = EncodingDetector.detect(ontology);
            ontologyManager.doImport(ontology, encoding);
          } catch (Exception t) {
            logger.error ("Error loading ontology: " + ontology.getAbsolutePath(), t);
            uc.add(new TrivialErrorUpdate("Error loading ontology: " + ontology.getAbsolutePath()));
          }
        } else {
          logger.error ("the file: " + ontology.getAbsolutePath() + " does not have proper format: xml/rdf/n3/ttl/owl");
          uc.add(new TrivialErrorUpdate("Error loading ontology: " + ontology.getAbsolutePath() + ". The file does not have proper format: xml/rdf/n3/ttl/owl"));
        }
      }
      // update the cache at the end when all files are added to the model
      ontologyManager.updateCache();
    } else {
      logger.info("No directory for preloading ontologies exists.");
    }
    SemanticTypeUtil.setSemanticTypeTrainingStatus(true);
  }
View Full Code Here

TOP

Related Classes of edu.isi.karma.modeling.ontology.OntologyManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.