You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by pk...@apache.org on 2013/05/15 17:01:45 UTC
svn commit: r1482880 - in /uima/sandbox/ruta/trunk/ruta-docbook/src/docbook:
tools.ruta.language.expressions.xml tools.ruta.language.syntax.xml
tools.ruta.overview.xml
Author: pkluegl
Date: Wed May 15 15:01:44 2013
New Revision: 1482880
URL: http://svn.apache.org/r1482880
Log:
UIMA-2904
- added some documentation for implicit actions/conditions
Modified:
uima/sandbox/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.language.expressions.xml
uima/sandbox/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.language.syntax.xml
uima/sandbox/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.overview.xml
Modified: uima/sandbox/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.language.expressions.xml
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.language.expressions.xml?rev=1482880&r1=1482879&r2=1482880&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.language.expressions.xml (original)
+++ uima/sandbox/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.language.expressions.xml Wed May 15 15:01:44 2013
@@ -301,4 +301,16 @@ BooleanListExpression -> BooleanListVa
</para>
</section>
</section>
+ <section id="ugr.tools.ruta.language.expressions.features">
+ <title>Feature Expressions</title>
+ <para>
+ Feature expression can be used in different situations, e.g., for resticting the match of a rule element,
+ as an implicit condition or as an implicit action.
+ <programlisting><![CDATA[FeatureExpression -> TypeExpression "." DottedIdentifier
+FeatureMatchExpression -> FeatureExpression "==" Expression
+FeatureAssignmentExpression -> FeatureExpression "=" Expression
+]]></programlisting>
+ </para>
+
+ </section>
</section>
\ No newline at end of file
Modified: uima/sandbox/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.language.syntax.xml
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.language.syntax.xml?rev=1482880&r1=1482879&r2=1482880&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.language.syntax.xml (original)
+++ uima/sandbox/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.language.syntax.xml Wed May 15 15:01:44 2013
@@ -119,6 +119,16 @@ Actions -> "->" Action (
<xref linkend='ugr.tools.ruta.language.expressions' />.
</para>
<para>
+ It is also possible to use specific expression as implicit conditions or action additionally to the set of available conditions and actions.
+ <programlisting><![CDATA[Condition -> BooleanExpression | FeatureMatchExpression
+Action -> TypeExpression | FeatureAssignmentExpression
+]]></programlisting>
+
+
+ </para>
+
+
+ <para>
Identifier:
<programlisting><![CDATA[DottedIdentifier -> Identifier ("." Identifier)*
DottedIdentifier2 -> Identifier (("."|"-") Identifier)*
Modified: uima/sandbox/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.overview.xml
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.overview.xml?rev=1482880&r1=1482879&r2=1482880&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.overview.xml (original)
+++ uima/sandbox/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.overview.xml Wed May 15 15:01:44 2013
@@ -181,6 +181,19 @@ W{REGEXP("dog") -> MARK(Animal)};]]></pr
</para>
<para>
+ There is also the possibility to add implicit actions and conditions, which have no explicit name, but consist only of an expression.
+ In the part of the conditions, boolean expressions and feature match expression can be applied, and in the part of the actions,
+ type expressions and feature assignment expression can be added. The following example contains one implicit condition and one implicit action.
+ The additional condition is a boolean expression (boolean variable), which is set to <quote>true</quote>, and therefore is always fulfills the condition.
+ The <quote>MARK</quote> action was replaced by a type expression, which refer to the type <quote>Animal</quote>. The follwong rule shows, therefore,
+ the same behavior as the rule in the last example.
+ </para>
+
+ <programlisting><![CDATA[DECLARE Animal;
+BOOLEAN active = true;
+W{REGEXP("dog"), active -> Animal};]]></programlisting>
+
+ <para>
There is also a special kind of rules, which follow a different syntax and semantic, and enables a simplified creation of annotations based on regular expression.
The following rule, for example, creates an <quote>Animal</quote> annotation for each occurrence of <quote>dog</quote> or <quote>cat</quote>.
</para>
@@ -369,7 +382,7 @@ STRING moneyCurrency;
NUM{PARSE(moneyAmount)} SPECIAL{REGEXP("â¬") -> MATCHEDTEXT(moneyCurrency),
CREATE(MoneyAmount, 1, 2, "amount" = moneyAmount,
"currency" = moneyCurrency)};]]></programlisting>
-
+
<para>
First, a new annotation with the name <quote>MoneyAmount</quote> and two features are defined, one string feature and one integer feature.
Then, two UIMA Ruta variables are declared, one integer variable and one string variable. The rule matches on a number, whose value is stored
@@ -379,6 +392,17 @@ NUM{PARSE(moneyAmount)} SPECIAL{REGEXP("
</para>
<para>
+ Using feature expression for conditions and action, can reduce the complexity of a rule. The first rule in the follwing example set the value of the feature
+ <quote>currency</quote> of the annotation of the type <quote>MoneyAmount</quote> to <quote>Euro</quote>, if it was <quote>â¬</quote> before.
+ The second rule creates an annotation of the type <quote>LessThan</quote> for all annotations of the type <quote>MoneyAmount</quote>,
+ if their amount is less than 100 and the currency is <quote>Euro</quote>.
+ </para>
+
+ <programlisting><![CDATA[DECLARE LessThan;
+ MoneyAmount.currency=="â¬"{-> MoneyAmount.currency="Euro"};
+ MoneyAmount{(MoneyAmount.amount<=100), MoneyAmount.currency=="Euro" -> LessThan};]]></programlisting>
+
+ <para>
UIMA Ruta script files with many rules can quickly confuse the reader. The UIMA Ruta language, therefore, allows to import other script files in order to increase
the modularity of a project or to create rule libraries. The next example imports the rules together with all known types of another script file
and executes that script file.