Search Mailing List Archives
[protege-discussion] How to recover slot values?
Jonathan Carter
jonathan.carter at e-asolutions.com
Wed Oct 1 01:52:33 PDT 2008
Hi Emmanuel,
Try something like this:
aSlotValue = anInstance.getDirectOwnSlotValue(kb.getSlot("slot_name"))
The argument for the kb.getSlot() method is a string which is the name
of the slot you want to get the value of.
As you can see from the code snippet, you need to get a reference to
the specific instance. It might be that you need to get all the
Instances of a class and then iterate through them (this is Python
[Jython] code from a script but you can see the method calls that you
need to make - the Jython script calls the Java API), for example:
anInstanceList = kb.getCls("My_Class").getDirectInstances()
for anInstance in anInstanceList:
aSlotValue = anInstance.getDirectOwnSlotValue(kb.getSlot("slot_name"))
The methods that have the word 'Direct' in them just return Instances
or values of the specific class - which is normally what I want. You
can, however, use similar methods that have not got 'Direct' in their
name and they generally give you back things for the class that you
specified AND subclasses.
Have a look at the Javadoc, http://protege.stanford.edu/doc/pdk/api/index.html
and look at the Cls, Instance and Slot classes.
Hope this helps
Jonathan
__________________________________________
Jonathan Carter - Head of Technical Architecture
Enterprise Architecture Solutions Ltd
__________________________________________
Assess your EA maturity at:
www.enterprise-architecture.com/EAvaluator
__________________________________________
On 1 Oct 2008, at 02:14, Emmanuel Ramos wrote:
> Wath methods to use to recover slot values?
>
> Novos endereços, o Yahoo! que você conhece. Crie um email novo com a
> sua cara @ymail.com ou
> @rocketmail.com._______________________________________________
> protege-discussion mailing list
> protege-discussion at lists.stanford.edu
> https://mailman.stanford.edu/mailman/listinfo/protege-discussion
>
> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.stanford.edu/pipermail/protege-discussion/attachments/20081001/2d52a8ec/attachment.html>
More information about the protege-discussion
mailing list