@Override protected void initialize() { _definitionOrderTaxonomy = new TaxonomyImpl<>(_kb.getClasses(), ATermUtils.TOP, ATermUtils.BOTTOM); }
@Override protected void initialize() { _definitionOrderTaxonomy = new TaxonomyImpl<>(_kb.getClasses(), ATermUtils.TOP, ATermUtils.BOTTOM); }
@Override public boolean classify() { _builder.addAll(_kb.getClasses()); return true; }
@Override public boolean classify() { _builder.addAll(_kb.getClasses()); return true; }
public void computeAll() // Call from the jena's SparqlDLExecution { if (!computed) { computKBCosts(); if (_logger.isLoggable(Level.FINE)) { _logger.fine(" NoSat cost : " + noSatCost + " ms."); _logger.fine(" OneSat cost : " + oneSatCost + " ms."); _logger.fine("Classify cost : " + classificationCost + " ms."); _logger.fine(" Realize cost : " + realizationCost + " ms."); _logger.fine(" IR cost : " + instanceRetrievalCost + " ms."); _logger.fine(" CR cost : " + classRetrievalCost + " ms."); } compute(new HashSet<>(_kb.getClasses()), new HashSet<>(_kb.getProperties())); computed = true; } }
public void computeAll() // Call from the jena's SparqlDLExecution { if (!computed) { computKBCosts(); if (_logger.isLoggable(Level.FINE)) { _logger.fine(" NoSat cost : " + noSatCost + " ms."); _logger.fine(" OneSat cost : " + oneSatCost + " ms."); _logger.fine("Classify cost : " + classificationCost + " ms."); _logger.fine(" Realize cost : " + realizationCost + " ms."); _logger.fine(" IR cost : " + instanceRetrievalCost + " ms."); _logger.fine(" CR cost : " + classRetrievalCost + " ms."); } compute(new HashSet<>(_kb.getClasses()), new HashSet<>(_kb.getProperties())); computed = true; } }
public static void printCounts(final KnowledgeBase kb) { final int classCount = kb.getClasses().size(); final int objPropertyCount = kb.getObjectProperties().size(); final int dataPropertyCount = kb.getDataProperties().size(); System.out.println("Expressivity : " + kb.getExpressivity()); System.out.println("Classes : " + classCount); System.out.println("Obj Properties : " + objPropertyCount); System.out.println("Data Properties: " + dataPropertyCount); printCounts(kb.getABox()); } }
public void computKBCosts() { final int classCount = _kb.getClasses().size(); final int indCount = _kb.getClasses().size(); // FIXME the following constants are chosen based on very limited // empirical analysis noSatCost = 1; oneSatCost = 2; // this is a very rough and pretty inaccurate estimate // of classification. the number of sat checks done during // classification varies widely but due to various optimizations // it is a relatively small percentage of the brute-force n^2 classificationCost = _kb.isClassified() ? noSatCost : classCount * classCount * oneSatCost / 10; // the same arguments for classification applies here too realizationCost = _kb.isRealized() ? noSatCost : classificationCost + oneSatCost * classCount * indCount; // instance retrieval performs sat checks on only individuals that // are not ruled out by obvious (non-)instance checks thus it is // again a very small percentage instanceRetrievalCost = _kb.isRealized() ? noSatCost : indCount * oneSatCost / 100; // either KB is realized and this operation is pretty much free or // we perform realization and pay the cost // NOTE: the behavior to realize the KB at every type retrieval query // is subject to change and would require a change here too classRetrievalCost = _kb.isRealized() ? noSatCost : realizationCost; }
public AbstractDefinitionOrder(final KnowledgeBase kb, final Comparator<ATerm> comparator) { _kb = kb; _comparator = comparator; _cyclicConcepts = CollectionUtils.makeIdentitySet(); _definitionOrder = new ArrayList<>(kb.getClasses().size() + 2); initialize(); processDefinitions(); _cyclicConcepts = computeCycles(); _definitionOrder = computeDefinitionOrder(); }
public AbstractDefinitionOrder(final KnowledgeBase kb, final Comparator<ATerm> comparator) { _kb = kb; _comparator = comparator; _cyclicConcepts = CollectionUtils.makeIdentitySet(); _definitionOrder = new ArrayList<>(kb.getClasses().size() + 2); initialize(); processDefinitions(); _cyclicConcepts = computeCycles(); _definitionOrder = computeDefinitionOrder(); }
protected void processDefinitions() { final boolean hasInverses = _kb.getExpressivity().hasInverse(); final TBox tbox = _kb.getTBox(); for (final ATermAppl c : _kb.getClasses()) { final Iterator<Unfolding> unfoldingList = tbox.unfold(c); while (unfoldingList.hasNext()) { final Unfolding unf = unfoldingList.next(); final Set<ATermAppl> usedByC = ATermUtils.findPrimitives(unf.getResult(), !hasInverses, true); for (final ATermAppl used : usedByC) { if (!_kb.getClasses().contains(used)) continue; addUses(c, used); } } } }
protected void processDefinitions() { final boolean hasInverses = _kb.getExpressivity().hasInverse(); final TBox tbox = _kb.getTBox(); for (final ATermAppl c : _kb.getClasses()) { final Iterator<Unfolding> unfoldingList = tbox.unfold(c); while (unfoldingList.hasNext()) { final Unfolding unf = unfoldingList.next(); final Set<ATermAppl> usedByC = ATermUtils.findPrimitives(unf.getResult(), !hasInverses, true); for (final ATermAppl used : usedByC) { if (!_kb.getClasses().contains(used)) continue; addUses(c, used); } } } }
protected void reset() { _kb.prepare(); _classes = new ArrayList<>(_kb.getClasses()); _useCD = OpenlletOptions.USE_CD_CLASSIFICATION && !_kb.getTBox().unfold(ATermUtils.TOP).hasNext() && !_kb.getExpressivity().hasNominal(); init(); }
protected void reset() { _kb.prepare(); _classes = new ArrayList<>(_kb.getClasses()); _useCD = OpenlletOptions.USE_CD_CLASSIFICATION && !_kb.getTBox().unfold(ATermUtils.TOP).hasNext() && !_kb.getExpressivity().hasNominal(); init(); }
@Override protected void initialize() { _equivalents = CollectionUtils.makeIdentityMap(); _graph = new DefaultDirectedGraph<>(DefaultEdge.class); _graph.addVertex(TOP); for (final ATermAppl c : _kb.getClasses()) _graph.addVertex(c); }
private void createConcepts() { TOP = createConcept(ATermUtils.TOP); BOTTOM = createConcept(ATermUtils.BOTTOM); for (final ATermAppl c : _kb.getClasses()) createConcept(c); processAxioms(); _logger.fine("Process domain and ranges"); for (final ATermAppl c : _roleRestrictions.getRanges().values()) createConcept(c); for (final ATermAppl c : _roleRestrictions.getDomains().values()) createConcept(c); }
@Override protected void initialize() { _equivalents = CollectionUtils.makeIdentityMap(); _graph = new DefaultDirectedGraph<>(DefaultEdge.class); _graph.addVertex(TOP); for (final ATermAppl c : _kb.getClasses()) _graph.addVertex(c); }
private void createConcepts() { TOP = createConcept(ATermUtils.TOP); BOTTOM = createConcept(ATermUtils.BOTTOM); for (final ATermAppl c : _kb.getClasses()) createConcept(c); processAxioms(); _logger.fine("Process domain and ranges"); for (final ATermAppl c : _roleRestrictions.getRanges().values()) createConcept(c); for (final ATermAppl c : _roleRestrictions.getDomains().values()) createConcept(c); }
@Test public void complexAllUnsat() { _kb = new OWLAPILoader().createKB(MiscTests._base + "one+one-consistent-but-all-unsat.owl"); assertTrue(_kb.isConsistent()); assertEquals(_kb.getClasses(), _kb.getUnsatisfiableClasses()); }
@Test public void testTicket424() { classes(_A, _B, _C, _D, _E, _F, _G); objectProperties(_p, _q, _r, _s); final KBLoader loader = new JenaLoader(); final KnowledgeBase kb = loader.createKB(new String[] { "file:" + PelletTestSuite.base + "misc/ticket-424-test-case.owl" }); final Taxonomy<ATermAppl> toldTaxonomy = kb.getToldTaxonomy(); try { for (final ATermAppl aTerm : kb.getClasses()) { assertNotNull(toldTaxonomy.getNode(aTerm)); toldTaxonomy.getFlattenedSubs(TermFactory.TOP, false); } } catch (final NullPointerException e) { Log.error(_logger, e); fail("Caught NullPointerException when querying the told taxonomy."); } }