@Override public boolean contains(final KnowledgeBase kb, final GraphLoader loader, final Node subj, final Node pred, final Node obj) { return kb.getExpressivity().hasDisjointRoles(); } });
@Override public boolean contains(final KnowledgeBase kb, final GraphLoader loader, final Node subj, final Node pred, final Node obj) { return kb.getExpressivity().hasDisjointRoles(); } });
public default CompletionStrategy chooseStrategy(final ABox abox) { return chooseStrategy(abox, getExpressivity()); }
@Override public boolean contains(final KnowledgeBase kb, final GraphLoader loader, final Node subj, final Node pred, final Node obj) { return kb.getExpressivity().hasDisjointRoles(); } });
public default CompletionStrategy chooseStrategy(final ABox abox) { return chooseStrategy(abox, getExpressivity()); }
/** * Creates an empty _cache with at most <code>maxSize</code> elements which are neither named or negations of names. * * @param kb * @param maxSize */ public ConceptCacheLRU(final KnowledgeBase kb, final int maxSize) { super(maxSize); _cacheSafety = CacheSafetyFactory.createCacheSafety(kb.getExpressivity()); _primitive = new ConcurrentHashMap<>(); _nonPrimitive = Integer.MAX_VALUE == maxSize ? // new ConcurrentHashMap<>() : // as "size" is an integer and so size() can be greater than max-int, then the predicate removeEldestEntry will always be false. So we use a simpler data structure. Collections.synchronizedMap(new LinkedHashMap<ATermAppl, CachedNode>(16, 0.75f, true) { private static final long serialVersionUID = 3701638684292370398L; @Override protected boolean removeEldestEntry(final Map.Entry<ATermAppl, CachedNode> eldest) { return _nonPrimitive.size() > getMaxSize(); } }); }
/** * Creates an empty _cache with at most <code>maxSize</code> elements which are neither named or negations of names. * * @param kb * @param maxSize */ public ConceptCacheLRU(final KnowledgeBase kb, final int maxSize) { super(maxSize); _cacheSafety = CacheSafetyFactory.createCacheSafety(kb.getExpressivity()); _primitive = new ConcurrentHashMap<>(); _nonPrimitive = Integer.MAX_VALUE == maxSize ? // new ConcurrentHashMap<>() : // as "size" is an integer and so size() can be greater than max-int, then the predicate removeEldestEntry will always be false. So we use a simpler data structure. Collections.synchronizedMap(new LinkedHashMap<ATermAppl, CachedNode>(16, 0.75f, true) { private static final long serialVersionUID = 3701638684292370398L; @Override protected boolean removeEldestEntry(final Map.Entry<ATermAppl, CachedNode> eldest) { return _nonPrimitive.size() > getMaxSize(); } }); }
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()); } }
@Override protected void reset() { super.reset(); _hasComplexRoles = _kb.getExpressivity().hasTransitivity() || _kb.getExpressivity().hasComplexSubRoles(); _primaryQueue.clear(); _concepts.clear(); _existentials.clear(); _conjunctions.clear(); _roleChains = new RoleChainCache(_kb); _roleRestrictions = new RoleRestrictionCache(_kb.getRBox()); }
public boolean isClassified() { // what if expressivity should change because of the yet unapplied changes? return _modules != null && (!_extractor.isChanged() || !_extractor.isClassificationNeeded(_reasoner.getKB().getExpressivity())); }
@Override protected void reset() { super.reset(); _hasComplexRoles = _kb.getExpressivity().hasTransitivity() || _kb.getExpressivity().hasComplexSubRoles(); _primaryQueue.clear(); _concepts.clear(); _existentials.clear(); _conjunctions.clear(); _roleChains = new RoleChainCache(_kb); _roleRestrictions = new RoleRestrictionCache(_kb.getRBox()); }
public boolean isClassified() { // what if expressivity should change because of the yet unapplied changes? return _modules != null && (!_extractor.isChanged() || !_extractor.isClassificationNeeded(_reasoner.getKB().getExpressivity())); }
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(); }
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); } } } }
/** * @param name * @param nodeParam */ public CachedConceptNode(final ATermAppl name, final Individual nodeParam) { _name = name; Individual node = nodeParam; // if the _node is merged, get the representative _node and check // also if the merge depends on a _branch _isIndependent = node.getMergeDependency(true).isIndependent(); node = node.getSame(); _outEdges = copyEdgeList(node, true); _inEdges = copyEdgeList(node, false); // collect all transitive property values if (node.getABox().getKB().getExpressivity().hasNominal()) collectComplexPropertyValues(node); _types = CollectionUtils.makeIdentityMap(node.getDepends()); for (final Map.Entry<ATermAppl, DependencySet> e : _types.entrySet()) e.setValue(e.getValue().cache()); }
public Taxonomy<ATermAppl> getHierarchy() { assertTrue("Expressivity is not EL", _kb.getExpressivity().isEL()); TaxonomyBuilder builder = null; try { builder = builderClass.getConstructor(KnowledgeBase.class).newInstance(_kb); } catch (final Exception e) { throw new OpenError(e); } builder.setProgressMonitor(new SilentProgressMonitor()); builder.classify(); return builder.getTaxonomy(); }
@Test public void testELExpressivityAnonymousInverseRestriction() { classes(_C, _D); objectProperties(_p); _kb.addSubClass(_C, some(inv(_p), _D)); assertFalse(_kb.getExpressivity().isEL()); assertFalse(SimplifiedELClassifier.class.equals(_kb.getTaxonomyBuilder().getClass())); }
@Test public void testELExpressivityAnonymousInverseChain() { classes(_C, _D); objectProperties(_p, _q, _r); _kb.addSubProperty(list(_p, inv(_q)), _r); _kb.addSubClass(_C, some(_p, _D)); assertFalse(_kb.getExpressivity().isEL()); assertFalse(SimplifiedELClassifier.class.equals(_kb.getTaxonomyBuilder().getClass())); } }