Skip to content

Instantly share code, notes, and snippets.

@GiovanniBalestrieri
Created February 13, 2017 23:28
Show Gist options
  • Save GiovanniBalestrieri/f144ef9690080971d6c9a8b441d5e34c to your computer and use it in GitHub Desktop.
Save GiovanniBalestrieri/f144ef9690080971d6c9a8b441d5e34c to your computer and use it in GitHub Desktop.
loading an onotlogy into memory
final String JENA_PATH = "/home/PATH/ontologies/";
final String SOURCE = "http://www.semanticweb.org/ontologies/2016/1/";
final String TBOX_FILE = "semantic_mapping_domain_model.owl";
final String ABOX_FILE = "semantic_map1.owl";
/**
* Importing Tbox
*/
OntModel tbox = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
OntDocumentManager dm_tbox = tbox.getDocumentManager();
dm_tbox.addAltEntry(SOURCE+TBOX_FILE,"file:"+TBOX_FILE);
tbox.read(SOURCE+TBOX_FILE,"RDF/XML");
/**
* Importing Abox
*/
OntModel abox = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM);
OntDocumentManager dma = abox.getDocumentManager();
dma.addAltEntry( SOURCE + ABOX_FILE , "file:" + ABOX_FILE);
abox.read(SOURCE + ABOX_FILE,"RDF/XML");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment