本文整理匯總了Java中org.semanticweb.owlapi.model.OWLOntologyManager.removeOntology方法的典型用法代碼示例。如果您正苦於以下問題:Java OWLOntologyManager.removeOntology方法的具體用法?Java OWLOntologyManager.removeOntology怎麽用?Java OWLOntologyManager.removeOntology使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.semanticweb.owlapi.model.OWLOntologyManager
的用法示例。
在下文中一共展示了OWLOntologyManager.removeOntology方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: create
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
@Override
public InferenceProvider create(ModelContainer model) throws OWLOntologyCreationException, InterruptedException {
OWLOntology ont = model.getAboxOntology();
final OWLOntologyManager m = ont.getOWLOntologyManager();
OWLOntology module = null;
OWLReasoner reasoner = null;
try {
InferenceProvider provider;
synchronized (ont) {
concurrentLock.acquire();
try {
if (useSLME) {
LOG.info("Creating for module: "+model.getModelId());
ModuleType mtype = ModuleType.BOT;
SyntacticLocalityModuleExtractor sme = new SyntacticLocalityModuleExtractor(m, ont, mtype);
Set<OWLEntity> seeds = new HashSet<OWLEntity>(ont.getIndividualsInSignature());
module = ont = sme.extractAsOntology(seeds, IRI.generateDocumentIRI());
LOG.info("Done creating module: "+model.getModelId());
}
reasoner = rf.createReasoner(ont);
provider = MapInferenceProvider.create(reasoner, ont);
}
finally {
concurrentLock.release();
}
}
return provider;
}
finally {
if (reasoner != null) {
reasoner.dispose();
}
if (module != null) {
m.removeOntology(module);
}
}
}
示例2: dispose
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
public void dispose() {
final OWLOntologyManager m = getOWLOntologyManager();
if (aboxOntology != null) {
m.removeOntology(aboxOntology);
}
for(ModelChangeListener listener : listeners) {
listener.dispose();
}
listeners.clear();
}
示例3: generateBlankModel
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
/**
* Generates a blank model
*
* @param metadata
* @return modelId
* @throws OWLOntologyCreationException
*/
public ModelContainer generateBlankModel(METADATA metadata)
throws OWLOntologyCreationException {
// Create an arbitrary unique ID and add it to the system.
IRI modelId = generateId(modelIdPrefix);
if (modelMap.containsKey(modelId)) {
throw new OWLOntologyCreationException(
"A model already exists for this db: " + modelId);
}
LOG.info("Generating blank model for new modelId: " + modelId);
// create empty ontology, use model id as ontology IRI
final OWLOntologyManager m = graph.getManager();
final OWLOntology tbox = graph.getSourceOntology();
OWLOntology abox = null;
ModelContainer model = null;
try {
abox = m.createOntology(modelId);
// add imports to T-Box and additional ontologies via IRI
createImports(abox, tbox.getOntologyID(), metadata);
// generate model
model = new ModelContainer(modelId, tbox, abox);
} catch (OWLOntologyCreationException exception) {
if (abox != null) {
m.removeOntology(abox);
}
throw exception;
}
// add to internal map
modelMap.put(modelId, model);
return model;
}
示例4: experimentalLoadComplexAnnotationSolr
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
/**
* Experimental method for trying out the loading of complex_annotation doc type
*
* @param opts
* @throws Exception
*/
@CLIMethod("--solr-load-complex-annotations")
public void experimentalLoadComplexAnnotationSolr(Opts opts) throws Exception {
// Check to see if the global url has been set.
String url = sortOutSolrURL(globalSolrURL);
// Only proceed if our environment was well-defined.
if( legoCatalogs == null || legoFiles == null || legoCatalogs.isEmpty() || legoFiles.isEmpty() ){
LOG.warn("Lego environment not well defined--skipping.");
}else{
// Ready the environment for every pass.
ParserWrapper pw = new ParserWrapper();
// Add all of the catalogs.
for( File legoCatalog : legoCatalogs ){
pw.addIRIMapper(new CatalogXmlIRIMapper(legoCatalog));
}
OWLOntologyManager manager = pw.getManager();
OWLReasonerFactory reasonerFactory = new ElkReasonerFactory();
// Actual loading--iterate over our list and load individually.
for( File legoFile : legoFiles ){
String fname = legoFile.getName();
OWLReasoner currentReasoner = null;
OWLOntology ontology = null;
// TODO: Temp cover for missing group labels and IDs.
//String agID = legoFile.getCanonicalPath();
String agLabel = StringUtils.removeEnd(fname, ".owl");
String agID = new String(agLabel);
try {
ontology = pw.parseOWL(IRI.create(legoFile));
currentReasoner = reasonerFactory.createReasoner(ontology);
// Some sanity checks--some of the genereated ones are problematic.
boolean consistent = currentReasoner.isConsistent();
if( consistent == false ){
LOG.info("Skip since inconsistent: " + fname);
continue;
}
Set<OWLClass> unsatisfiable = currentReasoner.getUnsatisfiableClasses().getEntitiesMinusBottom();
// TODO - make configurable to allow fail fast
if (unsatisfiable.isEmpty() == false) {
LOG.info("Skip since unsatisfiable: " + fname);
continue;
}
Set<OWLNamedIndividual> individuals = ontology.getIndividualsInSignature();
Set<OWLAnnotation> modelAnnotations = ontology.getAnnotations();
OWLGraphWrapper currentGraph = new OWLGraphWrapper(ontology);
try {
LOG.info("Trying complex annotation load of: " + fname);
ComplexAnnotationSolrDocumentLoader loader =
new ComplexAnnotationSolrDocumentLoader(url, currentGraph, currentReasoner, individuals, modelAnnotations, agID, agLabel, fname);
loader.load();
} catch (SolrServerException e) {
LOG.info("Complex annotation load of " + fname + " at " + url + " failed!");
e.printStackTrace();
System.exit(1);
}
} finally {
// Cleanup reasoner and ontology.
if (currentReasoner != null) {
currentReasoner.dispose();
}
if (ontology != null) {
manager.removeOntology(ontology);
}
}
}
}
}
示例5: loadComplexAnnotationSolr
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
/**
* Experimental method for trying out the loading of complex_annotation doc type.
* Works with --read-ca-list <file>.
*
* @param opts
* @throws Exception
*/
@CLIMethod("--solr-load-complex-exp")
public void loadComplexAnnotationSolr(Opts opts) throws Exception {
// Check to see if the global url has been set.
String url = sortOutSolrURL(globalSolrURL);
// Only proceed if our environment was well-defined.
if( caFiles == null || caFiles.isEmpty() ){
LOG.warn("LEGO environment not well defined--will skip loading LEGO/CA.");
}else{
// NOTE: These two lines are remainders from old code, and I'm not sure of their place in this world of ours.
// I wish there was an arcitecture diagram somehwere...
OWLOntologyManager manager = pw.getManager();
OWLReasonerFactory reasonerFactory = new ElkReasonerFactory();
// Actual loading--iterate over our list and load individually.
for( String fname : caFiles ){
OWLReasoner currentReasoner = null;
OWLOntology ontology = null;
// TODO: Temp cover for missing group labels and IDs.
//String agID = legoFile.getCanonicalPath();
String pretmp = StringUtils.removeEnd(fname, ".owl");
String[] bits = StringUtils.split(pretmp, "/");
String agID = bits[bits.length -1];
String agLabel = new String(StringUtils.replaceOnce(agID, ":", "_"));
try {
ontology = pw.parseOWL(IRI.create(fname));
currentReasoner = reasonerFactory.createReasoner(ontology);
// Some sanity checks--some of the genereated ones are problematic.
boolean consistent = currentReasoner.isConsistent();
if( consistent == false ){
LOG.info("Skip since inconsistent: " + fname);
continue;
}
Set<OWLClass> unsatisfiable = currentReasoner.getUnsatisfiableClasses().getEntitiesMinusBottom();
if (unsatisfiable.isEmpty() == false) {
LOG.info("Skip since unsatisfiable: " + fname);
continue;
}
Set<OWLNamedIndividual> individuals = ontology.getIndividualsInSignature();
Set<OWLAnnotation> modelAnnotations = ontology.getAnnotations();
OWLGraphWrapper currentGraph = new OWLGraphWrapper(ontology);
try {
LOG.info("Trying complex annotation load of: " + fname);
ComplexAnnotationSolrDocumentLoader loader =
new ComplexAnnotationSolrDocumentLoader(url, currentGraph, currentReasoner, individuals, modelAnnotations, agID, agLabel, fname);
loader.load();
} catch (SolrServerException e) {
LOG.info("Complex annotation load of " + fname + " at " + url + " failed!");
e.printStackTrace();
System.exit(1);
}
} finally {
// Cleanup reasoner and ontology.
if (currentReasoner != null) {
currentReasoner.dispose();
}
if (ontology != null) {
manager.removeOntology(ontology);
}
}
}
}
}