[Pellet-users] getting all properties and their values

Michael Smith msmith at clarkparsia.com
Tue Jul 1 11:01:33 UTC 2008


On Tue, 2008-06-24 at 12:16 +0200, Alexander Becker wrote:

> How do I get a list of all properties in an ontology *and* their possible values?
> All properties can be retrieved by: reasoner.getKB().getProperties()

What is a possible value for a property?  In most cases, this will be an
infinite collection, so what are you hoping to have returned?

> But how do I get their values? I need a list of all values, that were given for such properties.
> 
> e.g. there is a property hasCase, and it may have such values like Accusative or Genitive.
> I need them all.

Are these (1) the individuals that have appeared as objects in object
property assertions using the hasCase object property or (2) the
enumerated range of the object property?

If (1), you can use kb.getPropertyValues(ATermAppl) which will return a
map from subject individual to a set containing individuals related to
the subject individual using the parameter object property.  There is
not a similar method for data properties in the KnowledgeBase interface.
You will have create a loop over individuals returned by
kb.retrieveIndividualsWithProperty(ATermAppl), for each one calling
kb.getDataPropertyValues.

Also, please consider using the OWL API instead of the internal ATerm
API.  In addition to being more stable, it offers better object
orientation, type safety and documentation.  The Reasoner class also
contains getPropertyValues(OWLObjectProperty) and
getPropertyValues(OWLDataProperty) which should satisfy your needs.


> There is a method called getPropertyValues(ATermAppl r, ATermAppl x), but javadoc tells me:
> [quote]
> org.​mindswap.​pellet.​KnowledgeBase
> public List<ATermAppl> getPropertyValues(ATermAppl r, ATermAppl x)
> Return all property values for a given property and subject value.
> Parameters:
> r x 
> Returns:
> List of ATermAppl objects.
> [/quote]
> 
> and I have no idea what the subject should be.

The r parameter is the property.  The x parameter is the individual for
which you are getting r "fillers".  I.e., this will let you find RDF
statements like

x r ?a .

Where the list returned is values for ?a


-- 
Mike Smith

Clark & Parsia



More information about the Pellet-users mailing list