本文整理汇总了Java中uk.ac.manchester.cs.owlapi.modularity.SyntacticLocalityModuleExtractor类的典型用法代码示例。如果您正苦于以下问题:Java SyntacticLocalityModuleExtractor类的具体用法?Java SyntacticLocalityModuleExtractor怎么用?Java SyntacticLocalityModuleExtractor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SyntacticLocalityModuleExtractor类属于uk.ac.manchester.cs.owlapi.modularity包,在下文中一共展示了SyntacticLocalityModuleExtractor类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: minimizedTranslate
import uk.ac.manchester.cs.owlapi.modularity.SyntacticLocalityModuleExtractor; //导入依赖的package包/类
/**
* Translate the given {@link GafDocument} into an OWL representation of the LEGO model.
* Additionally minimize the lego model and imports into one ontology module.
*
* @param gaf
* @return minimized lego ontology
*/
public OWLOntology minimizedTranslate(GafDocument gaf) {
OWLOntology all = translate(gaf);
final OWLOntologyManager m = all.getOWLOntologyManager();
SyntacticLocalityModuleExtractor sme = new SyntacticLocalityModuleExtractor(m, all, ModuleType.BOT);
Set<OWLEntity> sig = new HashSet<OWLEntity>(all.getIndividualsInSignature());
Set<OWLAxiom> moduleAxioms = sme.extract(sig);
try {
OWLOntology module = m.createOntology(IRI.generateDocumentIRI());
m.addAxioms(module, moduleAxioms);
return module;
} catch (OWLException e) {
throw new RuntimeException("Could not create minimized lego model.", e);
}
}
示例2: createModule
import uk.ac.manchester.cs.owlapi.modularity.SyntacticLocalityModuleExtractor; //导入依赖的package包/类
private void createModule(String ontologyId, String moduleName, Set<OWLEntity> signature)
throws OWLOntologyCreationException, IOException, OWLOntologyStorageException
{
// create a new manager, avoid unnecessary change events
final OWLOntologyManager m = OWLManager.createOWLOntologyManager();
// extract module
SyntacticLocalityModuleExtractor sme = new SyntacticLocalityModuleExtractor(m, mooncat.getOntology(), ModuleType.BOT);
Set<OWLAxiom> moduleAxioms = sme.extract(signature);
OWLOntology module = m.createOntology(IRI.generateDocumentIRI());
m.addAxioms(module, moduleAxioms);
// save module
OutputStream moduleOutputStream = null;
try {
moduleOutputStream = getOutputSteam(getModuleFileName(ontologyId, moduleName));
m.saveOntology(module, moduleOutputStream);
}
finally {
IOUtils.closeQuietly(moduleOutputStream);
}
}
示例3: createModule
import uk.ac.manchester.cs.owlapi.modularity.SyntacticLocalityModuleExtractor; //导入依赖的package包/类
private static void createModule(String moduleName, Set<OWLEntity> signature, OWLOntology ont)
throws OWLOntologyCreationException, IOException, OWLOntologyStorageException
{
// create a new manager avoid unnecessary change events
final OWLOntologyManager m = OWLManager.createOWLOntologyManager();
// extract module
SyntacticLocalityModuleExtractor sme = new SyntacticLocalityModuleExtractor(m, ont, ModuleType.BOT);
Set<OWLAxiom> moduleAxioms = sme.extract(signature);
OWLOntology module = m.createOntology(IRI.generateDocumentIRI());
m.addAxioms(module, moduleAxioms);
// save module
OutputStream moduleOutputStream = null;
try {
moduleOutputStream = new FileOutputStream(getModuleFile(moduleName));
m.saveOntology(module, moduleOutputStream);
}
finally {
IOUtils.closeQuietly(moduleOutputStream);
}
}
示例4: getModule
import uk.ac.manchester.cs.owlapi.modularity.SyntacticLocalityModuleExtractor; //导入依赖的package包/类
public Set<OWLAxiom> getModule(Set<OWLAxiom> axioms) {
if (useModularisation) {
if (axioms.isEmpty()) {
return Collections.emptySet();
}
OWLOntologyManager man2 = OWLManager.createOWLOntologyManager();
moduleType = ModuleType.STAR;
SyntacticLocalityModuleExtractor extractor = new SyntacticLocalityModuleExtractor(man2, createEmptyOntology(man2), axioms, moduleType);
return extractor.extract(getEntailmentSignature());
}
else {
return axioms;
}
}
示例5: create
import uk.ac.manchester.cs.owlapi.modularity.SyntacticLocalityModuleExtractor; //导入依赖的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);
}
}
}
示例6: computeModule
import uk.ac.manchester.cs.owlapi.modularity.SyntacticLocalityModuleExtractor; //导入依赖的package包/类
private Set<OWLAxiom> computeModule(Set<OWLAxiom> contraction, EntailmentChecker checker) {
try {
OWLOntologyManager man = OWLManager.createOWLOntologyManager();
OWLOntology ont = man.createOntology(contraction);
SyntacticLocalityModuleExtractor extractor = new SyntacticLocalityModuleExtractor(man, ont, ModuleType.BOT);
return extractor.extract(checker.getEntailmentSignature());
}
catch (OWLOntologyCreationException e) {
throw new OWLRuntimeException(e);
}
}
示例7: extractModule
import uk.ac.manchester.cs.owlapi.modularity.SyntacticLocalityModuleExtractor; //导入依赖的package包/类
public static OWLOntology extractModule(Set<OWLEntity> signature, OWLOntology o, String modName, ModuleType moduleType)
throws OWLOntologyCreationException {
SyntacticLocalityModuleExtractor extractor = new SyntacticLocalityModuleExtractor(o.getOWLOntologyManager(), o, moduleType);
return extractor.extractAsOntology(signature, IRI.create(modName));
}
示例8: preCheckOntology
import uk.ac.manchester.cs.owlapi.modularity.SyntacticLocalityModuleExtractor; //导入依赖的package包/类
protected int preCheckOntology(String inConsistentMsg, String unsatisfiableMsg, String unsatisfiableModule) throws OWLException, IOException {
// pre-check: only try to load ontology iff:
// * ontology is consistent
// * no unsatisfiable classes
OWLReasoner currentReasoner = reasoner;
boolean disposeReasoner = false;
try {
if (currentReasoner == null) {
disposeReasoner = true;
currentReasoner = new ElkReasonerFactory().createReasoner(g.getSourceOntology());
}
boolean consistent = currentReasoner.isConsistent();
if (consistent == false) {
LOG.error(inConsistentMsg);
return -1;
}
Set<OWLClass> unsatisfiable = currentReasoner.getUnsatisfiableClasses().getEntitiesMinusBottom();
if (unsatisfiable.isEmpty() == false) {
LOG.error(unsatisfiableMsg);
OWLPrettyPrinter prettyPrinter = getPrettyPrinter();
for (OWLClass owlClass : unsatisfiable) {
LOG.error("Unsatisfiable: "+prettyPrinter.render(owlClass));
}
LOG.info("Creating module for unsatisfiable classes in file: "+unsatisfiableModule);
ModuleType mtype = ModuleType.BOT;
OWLOntologyManager m = g.getManager();
SyntacticLocalityModuleExtractor sme = new SyntacticLocalityModuleExtractor(m, g.getSourceOntology(), mtype );
Set<OWLEntity> seeds = new HashSet<OWLEntity>(unsatisfiable);
Set<OWLAxiom> axioms = sme.extract(seeds);
OWLOntology module = m.createOntology();
m.addAxioms(module, axioms);
File moduleFile = new File(unsatisfiableModule).getCanonicalFile();
m.saveOntology(module, IRI.create(moduleFile));
return -1;
}
}
finally {
if (disposeReasoner && currentReasoner != null) {
currentReasoner.dispose();
}
}
return 0;
}
示例9: checkModifiedDefinitions
import uk.ac.manchester.cs.owlapi.modularity.SyntacticLocalityModuleExtractor; //导入依赖的package包/类
/**
* Check if given change is a modified equivalence
* @param effAdds true if checking additions, false if checking removals
* @param man OWL ontology manager
* @param ax OWL axiom to be checked
* @param modExtractor Star module extractor
* @param newTerms Set of new terms used in this axiom
* @return Modified definition-type change, or null if not one
* @throws OWLOntologyCreationException Ontology creation exception
*/
private CategorisedChange checkModifiedDefinitions(boolean effAdds, OWLOntologyManager man, OWLAxiom ax,
SyntacticLocalityModuleExtractor modExtractor, Set<OWLEntity> newTerms) throws OWLOntologyCreationException {
CategorisedChange change = null;
Set<OWLAxiom> alignment = new HashSet<OWLAxiom>();
OWLEquivalentClassesAxiom equiv = (OWLEquivalentClassesAxiom) ax;
Set<OWLSubClassOfAxiom> subs = equiv.asOWLSubClassOfAxioms();
OWLSubClassOfAxiom sub1 = (OWLSubClassOfAxiom) subs.toArray()[0];
OWLClassExpression lhs = sub1.getSubClass();
OWLClassExpression rhs = sub1.getSuperClass();
Set<OWLAxiom> mod = modExtractor.extract(ax.getSignature());
loop:
for(OWLAxiom a : mod) {
if(a.isOfType(AxiomType.EQUIVALENT_CLASSES)) {
OWLEquivalentClassesAxiom y = (OWLEquivalentClassesAxiom) a;
Set<OWLSubClassOfAxiom> subs2 = y.asOWLSubClassOfAxioms();
for(OWLSubClassOfAxiom sub : subs2) {
boolean isEquiv = false;
if(sub.getSubClass().equals(lhs)) {
if(emptyOntReasoner.isEntailed(df.getOWLSubClassOfAxiom(sub.getSuperClass(), rhs)) ||
emptyOntReasoner.isEntailed(df.getOWLSubClassOfAxiom(rhs, sub.getSuperClass())))
isEquiv = true;
}
else if(sub.getSubClass().equals(rhs)) {
if(emptyOntReasoner.isEntailed(df.getOWLSubClassOfAxiom(sub.getSuperClass(), lhs)) ||
emptyOntReasoner.isEntailed(df.getOWLSubClassOfAxiom(lhs, sub.getSuperClass())))
isEquiv = true;
}
else if(sub.getSuperClass().equals(lhs)) {
if(emptyOntReasoner.isEntailed(df.getOWLSubClassOfAxiom(sub.getSubClass(), rhs)) ||
emptyOntReasoner.isEntailed(df.getOWLSubClassOfAxiom(rhs, sub.getSubClass())))
isEquiv = true;
}
else if(sub.getSuperClass().equals(lhs)) {
if(emptyOntReasoner.isEntailed(df.getOWLSubClassOfAxiom(sub.getSubClass(), lhs)) ||
emptyOntReasoner.isEntailed(df.getOWLSubClassOfAxiom(lhs, sub.getSubClass())))
isEquiv = true;
}
if(isEquiv) {
alignment.add(a);
break loop;
}
}
}
}
if(!alignment.isEmpty()) {
if(effAdds) {
if(newTerms.isEmpty())
change = new CategorisedEffectualAddition(ax, EffectualAdditionCategory.MODIFIEDDEFINITION, alignment, newTerms);
else
change = new CategorisedEffectualAddition(ax, EffectualAdditionCategory.MODIFIEDDEFINITIONNT, alignment, newTerms);
}
else {
if(newTerms.isEmpty())
change = new CategorisedEffectualRemoval(ax, EffectualRemovalCategory.MODIFIEDDEFINITION, alignment, newTerms);
else
change = new CategorisedEffectualRemoval(ax, EffectualRemovalCategory.MODIFIEDDEFINITIONRT, alignment, newTerms);
}
}
return change;
}
示例10: getExplanations
import uk.ac.manchester.cs.owlapi.modularity.SyntacticLocalityModuleExtractor; //导入依赖的package包/类
/**
* Gets explanations for an entailment, with limit on the number of explanations returned.
* @param entailment The entailment for which explanations will be generated.
* @param limit The maximum number of explanations to generate. This should be a positive integer.
* @return A set containing explanations. The maximum cardinality of the set is specified by the limit parameter.
* The set may be empty if the entailment does not hold, or if a limit of zero or less is supplied.
* @throws org.semanticweb.owl.explanation.api.ExplanationException
* if there was a problem generating the explanation.
*/
public Set<Explanation<OWLAxiom>> getExplanations(OWLAxiom entailment, int limit) throws ExplanationException {
final Set<OWLEntity> signature = new HashSet<OWLEntity>();
for(OWLAxiom ax : inputAxioms) {
signature.addAll(ax.getSignature());
}
final OWLDataFactory dataFactory = new OWLDataFactoryImpl();
AxiomTransformation transformation = new DeltaPlusTransformation(dataFactory);
OWLOntologyManager man = OWLManager.createOWLOntologyManager();
SyntacticLocalityModuleExtractor extractor = new SyntacticLocalityModuleExtractor(man, (OWLOntology) null, inputAxioms, ModuleType.STAR);
Set<OWLAxiom> moduleAxioms = extractor.extract(entailment.getSignature());
//
// ExplanationGenerator<OWLAxiom> regGen = delegateFactory.createExplanationGenerator(inputAxioms, new NullExplanationProgressMonitor<OWLAxiom>());
// Set<Explanation<OWLAxiom>> regexpls = regGen.getExplanations(entailment);
// System.out.println(".........................................................");
Set<OWLAxiom> flattenedAxioms = transformation.transform(moduleAxioms);
ExplanationGenerator<OWLAxiom> gen = delegateFactory.createExplanationGenerator(flattenedAxioms);
Set<Explanation<OWLAxiom>> expls = gen.getExplanations(entailment);
// System.out.println("Found " + expls.size() + " regular expls");
// for(Explanation<OWLAxiom> expl : expls) {
// System.out.println(expl);
// }
// if(expls.isEmpty()) {
// {
// System.out.println("Not found any delta plus justifications!");
// for(OWLAxiom ax : flattenedAxioms) {
// System.out.println(ax);
// }
// System.out.println("........................................................");
// DeltaTransformationUnfolder unfolder = new DeltaTransformationUnfolder(dataFactory);
// Set<OWLAxiom> unfoldedAxioms = unfolder.getUnfolded(flattenedAxioms, signature);
// for(OWLAxiom ax : unfoldedAxioms) {
// System.out.println(ax);
// }
// }
IsLaconicChecker checker = new IsLaconicChecker(dataFactory, entailmentCheckerFactory, LaconicCheckerMode.EARLY_TERMINATING);
Set<Explanation<OWLAxiom>> laconicExplanations = new HashSet<Explanation<OWLAxiom>>();
Set<Explanation<OWLAxiom>> nonLaconicExplanations = new HashSet<Explanation<OWLAxiom>>();
for(Explanation<OWLAxiom> expl : expls) {
DeltaTransformationUnfolder unfolder = new DeltaTransformationUnfolder(dataFactory);
Set<OWLAxiom> unfoldedAxioms = unfolder.getUnfolded(expl.getAxioms(), signature);
Explanation<OWLAxiom> unfoldedExpl = new Explanation<OWLAxiom>(entailment, unfoldedAxioms);
if(checker.isLaconic(unfoldedExpl)) {
boolean added = laconicExplanations.add(unfoldedExpl);
if (added) {
progressMonitor.foundExplanation(this, unfoldedExpl, new HashSet<Explanation<OWLAxiom>>(laconicExplanations));
}
}
else {
nonLaconicExplanations.add(unfoldedExpl);
}
}
if(laconicExplanations.isEmpty()) {
System.out.println("NOT-FOUND-ANY!");
for(Explanation<OWLAxiom> nonLaconic : nonLaconicExplanations) {
System.out.println("NON-LACONIC:");
System.out.println(nonLaconic);
}
}
return laconicExplanations;
}
开发者ID:matthewhorridge,项目名称:owlexplanation,代码行数:73,代码来源:LaconicExplanationGeneratorBasedOnDeltaPlus.java
示例11: extractModule
import uk.ac.manchester.cs.owlapi.modularity.SyntacticLocalityModuleExtractor; //导入依赖的package包/类
private OWLOntology extractModule( OWLOntologyManager man,
OWLOntology ont,
Set<OWLEntity> signature) {
SyntacticLocalityModuleExtractor extractor = new SyntacticLocalityModuleExtractor(man, ont, ModuleType.STAR);
try {
return extractor.extractAsOntology( signature, IRI.create(MODULE_IRI) );
} catch( OWLOntologyCreationException e ) {
throw new RuntimeException("Module extraction error", e);
}
}