You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Zé Gildo Araújo <ze...@gmail.com> on 2012/11/16 18:15:57 UTC

How Can I generate a minimum graph?

Hi guys,

I would like to know :

1 - In a OntModel class the listHierarchyRootClasses method enables a
Top-Down navegation. But how can I obtain the leaves of my structure ? How
can I build a bottom-up strategy ?

2 - If I have in my model transitive properties for example:  "IsA,
MemberOf, PartOf" the listSubClasses method is not enough to get this
conections. How can I use the inferece machine to summarize a Model
containing transitive properties ? I build a model automatically. In this
process many redundant statements are added.

Example:

dog IsA mammal
mammal IsA animal
dog IsA animal (This is a redundant statement and do not necessary)

listHierarchyRootClasses will return "animal" - OK, but "mammal" will not
be returned by the listSubClasses method, the "IsA" transitive propertie
not be recognized in the navegation :(.

How Can I generate a minimum graph from my example ?


Thank you so much!
José



-- 
"Nor better, nor worse... just different."

Re: How Can I generate a minimum graph?

Posted by Dave Reynolds <da...@gmail.com>.
On 16/11/12 17:15, Zé Gildo Araújo wrote:
> Hi guys,
>
> I would like to know :
>
> 1 - In a OntModel class the listHierarchyRootClasses method enables a
> Top-Down navegation. But how can I obtain the leaves of my structure ? How
> can I build a bottom-up strategy ?

The term "leaf" suggest that your ontology is tree shaped in which case 
you could list all the classes and choose the ones that don't have 
sub-classes. Though beware that the sub-class graph need not be tree 
shaped, for example you can have a loop of sub-class relations that the 
simple find-a-leaf strategy will not identify.

> 2 - If I have in my model transitive properties for example:  "IsA,
> MemberOf, PartOf" the listSubClasses method is not enough to get this
> conections. How can I use the inferece machine to summarize a Model
> containing transitive properties ? I build a model automatically. In this
> process many redundant statements are added.
>
> Example:
>
> dog IsA mammal
> mammal IsA animal
> dog IsA animal (This is a redundant statement and do not necessary)
>
> listHierarchyRootClasses will return "animal" - OK, but "mammal" will not
> be returned by the listSubClasses method, the "IsA" transitive propertie
> not be recognized in the navegation :(.

listHierarchyRootClasses and listSubClasses are looking at 
rdfs:subClassOf relationships. Your "IsA" has nothing to do that.

If you have declared IsA as transitive then include an OWL reasoner to 
get the transitive closure. But you can't traverse with listSubClasses 
that's only for sub-class relationships. Just query for your IsA relations:

    infModel.listStatements(null, isa, (RDFNode)null) etc

> How Can I generate a minimum graph from my example ?

If by "minimum" graph you want the transitive reduction (where redundant 
links have been omitted) then there is no convenient support.

There is some level machinery for that, but it is a bit hidden.

You can create a TransitiveGraphCache, giving it a term to use for the 
base relation (e.g. your IsA) and a term to use for the direct (reduced) 
version of the relation. Then you could add all the data from your model 
in the TGC instance and use TGC.find with the direct relation to find 
all the direct links.

The trouble with this is that it is intended for internal use in the 
reasoners and so works at the Graph level (Nodes and Triples) instead of 
the Model level (RDFNodes and Statements).

Dave