/** * {@inheritDoc} */ public NodeSet<OWLNamedIndividual> getInstances(OWLClassExpression ce, boolean direct) throws InconsistentOntologyException, ClassExpressionNotInProfileException, FreshEntitiesException, ReasonerInterruptedException, TimeOutException { if( ce.isAnonymous() && direct) { throw new UnsupportedOperationException( "This reasoner only supports named classes" ); } reasoner.flush(); if( !isRealized() && !direct ) { return reasoner.getInstances( ce, direct ); } realize(); Set<OWLNamedIndividual> individuals = direct ? TaxonomyUtils.<OWLClass, OWLNamedIndividual>getDirectInstances(taxonomy, (OWLClass) ce) : TaxonomyUtils.<OWLClass, OWLNamedIndividual>getAllInstances(taxonomy, (OWLClass) ce); return getIndividualNodeSet( individuals ); }
private Set<Set<ATermAppl>> getPrimitiveTypes(ATermAppl ind, boolean direct) { Set<Set<ATermAppl>> types = new HashSet<Set<ATermAppl>>(); for( Set<ATermAppl> t : TaxonomyUtils.getTypes( builder.getTaxonomy(), ind, direct ) ) { Set<ATermAppl> eqSet = ATermUtils.primitiveOrBottom( t ); if( !eqSet.isEmpty() ) types.add( eqSet ); } return types; }
private void addToldSubsumer(ATermAppl c, ATermAppl d, Set<ATermAppl> explanation) { TaxonomyNode<ATermAppl> cNode = toldTaxonomy.getNode( c ); TaxonomyNode<ATermAppl> dNode = toldTaxonomy.getNode( d ); if( cNode == null ) { throw new InternalReasonerException( c + " is not in the definition order" ); } if( dNode == null ) { throw new InternalReasonerException( d + " is not in the definition order" ); } if( cNode.equals( dNode ) ) { return; } if( cNode.equals( toldTaxonomy.getTop() ) ) { toldTaxonomy.merge( cNode, dNode ); TaxonomyUtils.clearSuperExplanation( toldTaxonomy, c ); } else { toldTaxonomy.addSuper( c, d ); toldTaxonomy.removeCycles( cNode ); if( cNode.getEquivalents().size() > 1 ) { TaxonomyUtils.clearSuperExplanation( toldTaxonomy, c ); } else if( explanation != null && !explanation.isEmpty() ) { TaxonomyUtils.addSuperExplanation( toldTaxonomy, c, d, explanation ); } } }
super.printNode( set ); Set<ATermAppl> instances = TaxonomyUtils.getDirectInstances( taxonomy, set.iterator().next() ); if(instances.size() > 0) { out.print(" - (");
Set<Set<ATermAppl>> exps = TaxonomyUtils.getSuperExplanations( toldTaxonomy, c, n .getName() ); if( exps != null ) { for( Set<ATermAppl> exp : exps ) { if( !exp.isEmpty() ) { TaxonomyUtils.addSuperExplanation( taxonomy, c, n.getName(), exp );
/** * Returns all the instances of concept c. If TOP concept is used every * individual in the knowledge base will be returned * * @param c * class whose instances are returned * @return A set of ATerm objects */ public Set<ATermAppl> getInstances(ATermAppl c) { if( !isClass( c ) ) { handleUndefinedEntity( c + " is not a class!" ); return Collections.emptySet(); } if( instances.containsKey( c ) ) return instances.get( c ); else if( isRealized() ) { if( builder == null ) throw new NullPointerException( "Builder is null" ); Taxonomy<ATermAppl> taxonomy = builder.getTaxonomy(); if( taxonomy == null ) throw new NullPointerException( "Taxonomy is null" ); if( taxonomy.contains( c ) && ATermUtils.isPrimitive( c ) ) return TaxonomyUtils.getAllInstances( taxonomy, c ); } return new HashSet<ATermAppl>( retrieve( c, individuals ) ); }
private Set<OWLAxiom> getCachedExplanation(OWLClassExpression unsatClass) { PelletReasoner pellet = getReasoner(); if( !pellet.getKB().isClassified() ) return null; Pair<OWLClass,OWLClass> pair = getSubClassAxiom( unsatClass ); if( pair != null ) { Set<Set<ATermAppl>> exps = TaxonomyUtils.getSuperExplanations( pellet.getKB().getTaxonomy(), pellet.term( pair.first ), pellet.term( pair.second ) ); if( exps != null ) { Set<OWLAxiom> result = convertExplanation( exps.iterator().next() ); if( log.isLoggable( Level.FINE ) ) log.fine( "Cached explanation: " + result ); return result; } } return null; }
private void addToldEquivalent(ATermAppl c, ATermAppl d) { if( c.equals( d ) ) { return; } TaxonomyNode<ATermAppl> cNode = toldTaxonomy.getNode( c ); TaxonomyNode<ATermAppl> dNode = toldTaxonomy.getNode( d ); toldTaxonomy.merge( cNode, dNode ); TaxonomyUtils.clearSuperExplanation( toldTaxonomy, c ); }
public boolean isType(ATermAppl x, ATermAppl c) { ensureConsistency(); if( !isIndividual( x ) ) { handleUndefinedEntity( x + " is not an individual!" ); return false; } if( !isClass( c ) ) { handleUndefinedEntity( c + " is not a valid class expression" ); return false; } if( isRealized() && !doExplanation() ) { if( builder == null ) throw new NullPointerException( "Builder is null" ); Taxonomy<ATermAppl> taxonomy = builder.getTaxonomy(); if( taxonomy == null ) throw new NullPointerException( "Taxonomy is null" ); if( taxonomy.contains( c ) ) return TaxonomyUtils.isType( taxonomy, x, c ); } return abox.isType( x, c ); }
super.printNode( set ); Set<ATermAppl> instances = TaxonomyUtils.getDirectInstances( taxonomy, set.iterator().next() ); if(instances.size() > 0) { out.print(" - (");
Set<Set<ATermAppl>> exps = TaxonomyUtils.getSuperExplanations( toldTaxonomy, c, n .getName() ); if( exps != null ) { for( Set<ATermAppl> exp : exps ) { if( !exp.isEmpty() ) { TaxonomyUtils.addSuperExplanation( taxonomy, c, n.getName(), exp );
/** * Returns all the instances of concept c. If TOP concept is used every * individual in the knowledge base will be returned * * @param c * class whose instances are returned * @return A set of ATerm objects */ public Set<ATermAppl> getInstances(ATermAppl c) { if( !isClass( c ) ) { handleUndefinedEntity( c + " is not a class!" ); return Collections.emptySet(); } if( instances.containsKey( c ) ) return instances.get( c ); else if( isRealized() ) { if( builder == null ) throw new NullPointerException( "Builder is null" ); Taxonomy<ATermAppl> taxonomy = builder.getTaxonomy(); if( taxonomy == null ) throw new NullPointerException( "Taxonomy is null" ); if( taxonomy.contains( c ) && ATermUtils.isPrimitive( c ) ) return TaxonomyUtils.getAllInstances( taxonomy, c ); } return new HashSet<ATermAppl>( retrieve( c, individuals ) ); }
private void addToldEquivalent(ATermAppl c, ATermAppl d) { if( c.equals( d ) ) { return; } TaxonomyNode<ATermAppl> cNode = toldTaxonomy.getNode( c ); TaxonomyNode<ATermAppl> dNode = toldTaxonomy.getNode( d ); toldTaxonomy.merge( cNode, dNode ); TaxonomyUtils.clearSuperExplanation( toldTaxonomy, c ); }
public boolean isType(ATermAppl x, ATermAppl c) { ensureConsistency(); if( !isIndividual( x ) ) { handleUndefinedEntity( x + " is not an individual!" ); return false; } if( !isClass( c ) ) { handleUndefinedEntity( c + " is not a valid class expression" ); return false; } if( isRealized() && !doExplanation() ) { if( builder == null ) throw new NullPointerException( "Builder is null" ); Taxonomy<ATermAppl> taxonomy = builder.getTaxonomy(); if( taxonomy == null ) throw new NullPointerException( "Taxonomy is null" ); if( taxonomy.contains( c ) ) return TaxonomyUtils.isType( taxonomy, x, c ); } return abox.isType( x, c ); }
public ATermAppl getType(ATermAppl ind, boolean direct) { if( !isIndividual( ind ) ) { handleUndefinedEntity( ind + " is not an individual!" ); return null; } realize(); for( Set<ATermAppl> t : TaxonomyUtils.getTypes( builder.getTaxonomy(), ind, direct ) ) { Set<ATermAppl> eqSet = ATermUtils.primitiveOrBottom( t ); if( !eqSet.isEmpty() ) return eqSet.iterator().next(); } return null; }
Set<ATermAppl> instances = TaxonomyUtils.getDirectInstances( taxonomy, c ); for( ATermAppl instance : instances ) { if( ATermUtils.isBnode( instance ) )
return TaxonomyUtils.getAllInstances(taxonomy, owlClass);
private void addToldSubsumer(ATermAppl c, ATermAppl d, Set<ATermAppl> explanation) { TaxonomyNode<ATermAppl> cNode = toldTaxonomy.getNode( c ); TaxonomyNode<ATermAppl> dNode = toldTaxonomy.getNode( d ); if( cNode == null ) { throw new InternalReasonerException( c + " is not in the definition order" ); } if( dNode == null ) { throw new InternalReasonerException( d + " is not in the definition order" ); } if( cNode.equals( dNode ) ) { return; } if( cNode.equals( toldTaxonomy.getTop() ) ) { toldTaxonomy.merge( cNode, dNode ); TaxonomyUtils.clearSuperExplanation( toldTaxonomy, c ); } else { toldTaxonomy.addSuper( c, d ); toldTaxonomy.removeCycles( cNode ); if( cNode.getEquivalents().size() > 1 ) { TaxonomyUtils.clearSuperExplanation( toldTaxonomy, c ); } else if( explanation != null && !explanation.isEmpty() ) { TaxonomyUtils.addSuperExplanation( toldTaxonomy, c, d, explanation ); } } }
return TaxonomyUtils.getDirectInstances( taxonomy, c ); Iterator<ATermAppl> i = s.iterator(); ATermAppl term = i.next(); Set<ATermAppl> cand = TaxonomyUtils.getDirectInstances( taxonomy, term );