[rules-users] Re: Writing rules using terminology based expressions.

Greg Barton greg_barton at yahoo.com
Thu Aug 14 17:29:03 EDT 2008


Two possible approaches:

Create data structures that represent the semantic
relationships and assert them into working memory. 

class SemanticNode {

  int code;
  SemanticNode parent;

  public boolean isA(SemanticNode node) {
    if(code == node.code) {
      return true;
    } else {
      if(parent == null) {
        return false;
      } else {
        return parent.isA(node);
      }
    }
  }
}

Sample rule:

when 
  Diagnosis( $diagCode : code )
  $node : SemanticNode( code == $diagCode )
  $otherNode : SemanticNode()
  eval( $node.isA($otherNode) )
then
  ..do stuff...
end

This rule will match once on each ancestor of $node,
though.  It would execute faster if you had direct
pointers to each ancestor instead of just a parent
link.
  
--- Shahim Essaid <sessaid at essaid.com> wrote:

> Here is a very simplistic example:
> 
> I have a rule that wants to check for "cough"
> (concept ID 11111) symptom 
> in the working memory and the working memory has a
> "whooping cough" 
> concept (ID 22222) object.
> 
> The working memory object will be Concept(ID=22222)
> and the rule will 
> use Concpet(ID=11111).
> 
> A simple numerical comparison will fail but the
> concept id 22222 is a 
> 11111 and this IS_A relationship is in the
> terminology's semantic net. 
> This means that the rule should be activated in this
> condition.
> 
> Based on this simple example, what is the best way
> to include the 
> terminology's knowledge and the terminology's
> matching algorithm into 
> the rule engine?
> 
> Thanks,
> Shahim
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 



      



More information about the rules-users mailing list