Thank you for the hint with DOUBLE. This works for me too.
Regards,
Wolf-Dietrich Materna
-----Ursprüngliche Nachricht-----
Von: Peter Klügl [mailto:[email protected]]
Gesendet: Mittwoch, 26. April 2017 18:11
An: [email protected]
Betreff: Re: Ruta: order while execution of actions in rule?
Hi,
just a quick comment...
The actions are executed from left to right.
I tried to reproduce it (ruta 2.6.0). There seems to be a bug affecting the
FLOAT variable.
When I replace the line
FLOAT a2,a1;
with
DOUBLE a2,a1;
it seems to work.
I need to investigate it further in order to narrow down the cause.
Best,
Peter
Am 26.04.2017 um 14:18 schrieb Wolf-Dietrich Materna:
> Hello,
> I have a problem with the execution order of actions in rules.
> I want to use Ruta to extract numeric values and convert them for different
> units.
> Example input & expected output:
> “10 %” => annotation “Percent” with value 10.0
> “10 ‰” => annotation “Percent” with value 1.0 I wrote some simple
> rules for testing:
> DECLARE Annotation Percent(STRING class, FLOAT value, STRING unit );
> FLOAT a2,a1; // works as expected: value is 10.0 for input "10 %"
> (NUM{PARSE(a1)} "%") {-> CREATE (Percent, "value" = a1, "class" =
> "Percent", "unit" = "%")}; // Example 2: => returns wrong value 0.0. ASSIGN()
> is excecuted after CREATE() ?
> (NUM{PARSE(a1)} "‰") {-> ASSIGN(a1, a1/10), CREATE (Percent, "value" =
> a1, "class" = "Percent", "unit" = "‰")}; I tried Ruta 2.3.1 and 2.6.0, but
> the second rule doesn’t work as expected.
> The Percent annotation, which is created for “10 ‰”, has the value 10.0.
>
> It seems that the CREATE() action is executed before the ASSIGN() action.
> Is there any way to force Ruta to execute the ASSIGN() as first action?
> I expected that Ruta executes the actions from left to right, but in this
> case the order is different.
> I already tried other variants of the second rule, but this didn’t help:
> // returns value = 0.0 in annotation
> NUM{PARSE(a1) -> ASSIGN(a2, a1/10.0)} Tmpp10 {-> CREATE (Percent, 1,2,
> "value" = a2, "class" = "Percent", "unit" = "‰")}; Thank you in advance for
> an explanation or hint to solve the issue.
> Wolf-Dietrich Materna
>
>
>