[rules-users] Filter incorrect abbreviations

Edson Tirelli tirelli at post.com
Tue Jul 29 11:15:12 EDT 2008


   If you have each character in a different attribute, you can use "in" and
"not in" to list the valid/invalid characters:

      a : Abbreviation( pos1 == 'A', pos2 in ('-','D','H'), pos3 == '-',
pos4 in ('O', 'R', 'U', 'L') )
      a : Abbreviation( pos1 == 'A', pos2 not in ('-','D','H'), pos3 != '-',
pos4 not in ('O', 'R', 'U', 'L') )

  Also, if you have a String storing the sequence of characters you are
using, you can use "matches" and "not matches" with appropriate regexps:

      a : Abbreviation( stringRepresentation matches "A[-DH]-[ORUL]" )
      a : Abbreviation( stringRepresentation not matches "A[-DH]-[ORUL]" )

  Cheers,
      Edson

2008/7/28 Pete Crenshaw <Pete.Crenshaw at gmx.de>

> Hello Droolers,
>
> I'm a Drools novice and I'm stuck with a basic rule problem.
>
> In my domain I use a list of abbreviations to describe the conditions of a
> system.
> Before I can check the state of my system I have to verify all applied
> abbreviations.
>
> The List of abbreviations is not a fixed list it's more like a combination
> of chars, combined in different ways on fixed positions.
>
> This is a small cutout:
>
> A cutout of possible chars at Position 1: A B C D F H
> A cutout of possible chars at Position 2: - A C s n b
> A cutout of possible chars at Position 3: - A B E F M
> A cutout of possible chars at Position 4: - H L O R U
>
> Now it is allowed to combine the following abbreviations:
> (another small cutout)
>
> A--O     A--R     A--U    A--L
> BAAO     BAAR     BAAU    BAAL
>
> but it is not allowed to combine this:
>
> AA**     B-** (* stands for all possible chars on a position)
>
> Now I have 2 basic Questions:
>
> 1) How can I pick abbreviations that are NOT allowed?
>    I think it's easy to say:
>
>    rule "Rule 1"
>     when
>       a : Abbreviation( pos1 == 'A', pos2 == '-', pos3 == '-', pos4 == 'O'
> )
>     then
>       # do something positiv
>    end
>
>    But how can I pick up all the wrong combinations without hardcoding
> them?
>    This would end up in a never-ending story.
>
> 2) Upgrading the "Rule 1" from my 1st Question I'm looking for a way to
> make the
>    Rules more generic.
>    I don't want to hardcode all possible abbreviation combinations.
>    How can I realise something like this VERY INFORMAL notation:
>
>    rule "Rule 2"
>     when
>       a : Abbreviation( pos1 == 'A', pos2 == ['-','D','H'], pos3 == '-',
> pos4 == ['O', 'R', 'U', 'L'] )
>       # If abbreviation looks like A--O, AD-O, AD-U, AH-R, etc. everything
> is fine.
>       # It's time for "Rule 2" to do something positiv
>     then
>       # do something positiv
>    end
>
>    "Rule 2" should find all the abbreviations that are build up according
> to a set of allowed char combinations.
>
>    OR
>
>    rule "Rule 3"
>     when
>       a : Abbreviation( pos1 == 'A', pos2 != ['-','D','H'], pos3 != '-',
> pos4 != ['O', 'R', 'U', 'L'] )
>       # If abbreviation looks like AA-O, AB-U, A-AO, A--K, etc. something
> is wrong.
>       # It's time for "RULE 3" to announce something negative
>     then
>       # announce something negative
>    end
>
>    "Rule 3" should filter all the abbreviations that are violating a set of
> allowed char combinations.
>
> Thanx 2 all droolers in advance.
>
> Pete
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
Edson Tirelli
JBoss Drools Core Development
JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20080729/4220ded0/attachment.html 


More information about the rules-users mailing list