As can be frequently seen on this list (as well as on others) the lack of
precision in the original definition of the transformation is striking.
Now that we know that S -> VOL and SF -> S must be done in parallel, and
that arbitrary combinations of the input strings need to be handled, we
still don't know what should become of
SFFF
Application of the second rule produces
SFF
and, by repeated application of the same rule, we finally obtain
S
Is this as it should be? Or is every input string to be replaced exactly
once, and inserted strings do not trigger another match?
The complete definition of the patterns to be replaced is
S(?!F) => VOL
SF => S
and we'd need a yes or no regarding the question raised in the first
paragraph.
A simple rule would look for strings containing an 'S', using no-loop, and
modifying the string (on the right hand side) by an application of
replaceAll for "S(?!F)" to "VOL", followed by another one, replacing
all
"SF" by "S", called repeatedly or not.
IMHO, there's no gain in trying to conceive elaborate rule combinations for
simple algorithms.
-W
On 24 November 2011 09:11, FrankVhh <frank.vanhoenshoven(a)agserv.eu> wrote:
I am sorry, but that would not work either. The first rule would not
catch
those sentences that have both S and SF in them.
You will have to work in three steps and use an intermediate value.
1. Change SF to Q
2. Change S to VOL
3. Change Q to S
Separate your steps by using ruleflow or agenda-groups. Make sure to update
your WM after every change.
Sorry for the confusion.
Regards,
Frank
FrankVhh wrote
>
> Hi,
>
> Sorry, but I fogot about you :-(.
>
> It does not work because both wolfgang and I did get your question wrong.
>
> If I were you, I would try to work from the opposite direction and check
> whether a String matches S but not SF. Than replace that S by VOL.
>
> A second rule could than safely check for SF and replace that by S.
>
> In short, reverse your salience, check that S is not SF and make sure
that
> you replace the right S in the RHS of your rules. You do not want to
> update the WM.
>
> Regards,
> Frank
>
>
> fiitkar wrote
>>
>> Sorry, it does not work.
>> For input SF I allways get VOLVOLFVOL.
>>
>> Once again: if the input is S the output should be VOL. But if the input
>> string contains SF the output should be S and not VOL.
>>
>> For example:
>> SF --> S
>> SSF --> VOLS
>> SFSF -> SS
>> etc.
>>
>
--
View this message in context:
http://drools.46999.n3.nabble.com/string-replace-collision-problem-tp3518...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users