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 2019/11/21 17:07:25 UTC

svn commit: r1870098 - in /uima/ruta/trunk: ruta-core/src/main/java/org/apache/uima/ruta/ ruta-core/src/test/java/org/apache/uima/ruta/expression/type/ ruta-docbook/src/docbook/

Author: pkluegl
Date: Thu Nov 21 17:07:25 2019
New Revision: 1870098

URL: http://svn.apache.org/viewvc?rev=1870098&view=rev
Log:
UIMA-4676: improve docs, added test for assigning type

Modified:
    uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java
    uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/expression/type/TypeFeatureTest.java
    uima/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.language.expressions.xml
    uima/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.language.xml
    uima/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.overview.xml
    uima/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.workbench.explain_perspective.xml

Modified: uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java?rev=1870098&r1=1870097&r2=1870098&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java (original)
+++ uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java Thu Nov 21 17:07:25 2019
@@ -65,10 +65,12 @@ import org.apache.uima.ruta.expression.a
 import org.apache.uima.ruta.expression.annotation.IAnnotationListExpression;
 import org.apache.uima.ruta.expression.bool.IBooleanExpression;
 import org.apache.uima.ruta.expression.bool.IBooleanListExpression;
+import org.apache.uima.ruta.expression.feature.CoveredTextFeature;
 import org.apache.uima.ruta.expression.feature.FeatureExpression;
 import org.apache.uima.ruta.expression.feature.GenericFeatureExpression;
 import org.apache.uima.ruta.expression.feature.LazyFeature;
 import org.apache.uima.ruta.expression.feature.SimpleFeatureExpression;
+import org.apache.uima.ruta.expression.feature.TypeFeature;
 import org.apache.uima.ruta.expression.number.INumberExpression;
 import org.apache.uima.ruta.expression.number.INumberListExpression;
 import org.apache.uima.ruta.expression.string.IStringExpression;
@@ -980,9 +982,10 @@ public class RutaStream extends FSIterat
 
   public void assignFeatureValue(FeatureStructure annotation, Feature feature,
           IRutaExpression value, MatchContext context) {
-    if (feature == null) {
+    if (feature == null || feature instanceof CoveredTextFeature
+            || feature instanceof TypeFeature) {
       throw new IllegalArgumentException(
-              "Not able to assign feature value (e.g., coveredText) in script "
+              "Not able to assign feature value (e.g., coveredText, type) in script "
                       + context.getParent().getName());
     }
     if (feature instanceof LazyFeature) {

Modified: uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/expression/type/TypeFeatureTest.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/expression/type/TypeFeatureTest.java?rev=1870098&r1=1870097&r2=1870098&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/expression/type/TypeFeatureTest.java (original)
+++ uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/expression/type/TypeFeatureTest.java Thu Nov 21 17:07:25 2019
@@ -18,6 +18,7 @@
  */
 package org.apache.uima.ruta.expression.type;
 
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
 import org.apache.uima.cas.CAS;
 import org.apache.uima.ruta.engine.Ruta;
 import org.apache.uima.ruta.engine.RutaTestUtils;
@@ -45,4 +46,15 @@ public class TypeFeatureTest {
 
   }
 
+  @Test(expected = AnalysisEngineProcessException.class)
+  public void testAssignType() throws Exception {
+
+    String document = "This is a test.";
+
+    String script = "cw:CW{-> cw.type = SW};\n";
+
+    CAS cas = RutaTestUtils.getCAS(document);
+    Ruta.apply(cas, script);
+  }
+
 }

Modified: uima/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.language.expressions.xml
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.language.expressions.xml?rev=1870098&r1=1870097&r2=1870098&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.language.expressions.xml (original)
+++ uima/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.language.expressions.xml Thu Nov 21 17:07:25 2019
@@ -25,19 +25,19 @@
   </para>
   <para>
   <emphasis role="bold">Definition:</emphasis>
-<programlisting><![CDATA[RutaExpression  ->   TypeExpression | NumberExpression | 
-                           StringExpression | BooleanExpression
-                           | ListExpression]]></programlisting>
+<programlisting><![CDATA[RutaExpression  ->   TypeExpression | AnnotationExpression 
+                     | StringExpression | BooleanExpression 
+                     | NumberExpression | ListExpression]]></programlisting>
   </para>
   <section id="ugr.tools.ruta.language.expressions.type">
     <title>Type Expressions</title>
     <para>
-      UIMA Ruta provides two kinds of type expressions.
+      UIMA Ruta provides several kinds of type expressions.
       <orderedlist numeration="arabic">
         <listitem>
           Declared annotation types (see
           <xref linkend='ugr.tools.ruta.language.declarations.type' />
-          ).
+          ) also including any types present in the type system of the CAS or defined in imported type systems.
         </listitem>
         <listitem>
           Type variables
@@ -45,18 +45,25 @@
           <xref linkend='ugr.tools.ruta.language.declarations.variable' />
           ).
         </listitem>
+        <listitem>
+          Type of an annotation expression 
+          (see
+          <xref linkend='ugr.tools.ruta.language.expressions.features' />
+          ).
+        </listitem>
       </orderedlist>
+    </para>
       <section>
         <title>
           <emphasis role="bold">Definition:</emphasis>
         </title>
         <para>
 <programlisting><![CDATA[TypeExpression  ->  AnnotationType | TypeVariable]]></programlisting>
-        </para>
+                    | AnnotationExpression.type</para>
       </section>
       <section>
         <title>
-          <emphasis role="bold">Example:</emphasis>
+          <emphasis role="bold">Examples:</emphasis>
         </title>
         <para>
           <programlisting><![CDATA[DECLARE Author;  // Author defines a type, therefore it is 
@@ -64,8 +71,69 @@
 TYPE typeVar;    // type variable typeVar is a type expression 
 Document{->ASSIGN(typeVar, Author)};]]></programlisting>
         </para>
+        <para>
+          <programlisting><![CDATA[e:Entity{-> e.type}; // the dot notation type refers to the type 
+          // of the anotation stored in the label a. In this example, 
+          // this type expression refers to the type Entity or a specific 
+          // subtype of Entity.]]></programlisting>
+        </para>
       </section>
+  </section>
+  
+  <section id="ugr.tools.ruta.language.expressions.annotation">
+    <title>Annotation Expressions</title>
+    <para>
+      UIMA Ruta provides several kinds of annotation expressions.
+      <orderedlist numeration="arabic">
+        <listitem>
+          Annotation variables
+          (see
+          <xref linkend='ugr.tools.ruta.language.declarations.variable' />
+          ).
+        </listitem>
+        <listitem>
+          Label expressions storing matched annotations (see 
+          <xref linkend=' ugr.tools.ruta.language.labels' />
+          ). Label expressions are on-the-fly defined (local) variables in the context of a rule.
+        </listitem>
+        <listitem>
+          Annotation implicit referenced by a type expression in the match context  (see
+          <xref linkend='ugr.tools.ruta.language.expressions.type' />
+          ).
+        </listitem>
+        <listitem>
+          Annotations stored in features of other annotations.
+          (see
+          <xref linkend='ugr.tools.ruta.language.expressions.features' />
+          ).
+        </listitem>
+      </orderedlist>
     </para>
+      <section>
+        <title>
+          <emphasis role="bold">Definition:</emphasis>
+        </title>
+        <para>
+<programlisting><![CDATA[AnnotationExpression  ->  AnnotationVariable | LabelExpression 
+                          | TypeExpression | FeatureExpression]]></programlisting>
+        </para>
+      </section>
+      <section>
+        <title>
+          <emphasis role="bold">Examples:</emphasis>
+        </title>
+        <para>
+          <programlisting><![CDATA[ANNOTATION anno; // a variable declaration for storing an annotation.
+e:Entity; // label expression e stored the annotation matched by the 
+          // rule element with the matching condition Entity.
+er:EmplRelation{-> er.employer = Employer}; // the type expression 
+          // Employer implicitly refers to annotations of the 
+          // type Employer in the context of the EmplRelation match.
+e:EmplRelation.employer; // this feature expression represents the 
+                         // annotation stored in the feature employer.                                       
+]]></programlisting>
+        </para>
+      </section>
   </section>
 
   <section id="ugr.tools.ruta.language.expressions.number">
@@ -274,9 +342,10 @@ BooleanLiteral    ->  "true" | "false"]]
           <emphasis role="bold">Definition:</emphasis>
         </title>
         <para>
-<programlisting><![CDATA[ListExpression  ->   WordListExpression | WordTableExpression |
-                     TypeListExpression | NumberListExpression |
-                     StringListExpression | BooleanListExpression
+<programlisting><![CDATA[ListExpression  ->   WordListExpression | WordTableExpression 
+                     | TypeListExpression | AnnotationListExpression
+                     | NumberListExpression | StringListExpression 
+                     | BooleanListExpression
 WordListExpression     ->  RessourceLiteral | WordListVariable
 WordTableExpression    ->  RessourceLiteral | WordTableVariable
 TypeListExpression     ->  TypeListVariable
@@ -317,6 +386,11 @@ FeatureAssignmentExpression -> FeatureEx
 ]]></programlisting>
     </para>
     <para>
+      Ruta allows the access of two special attributes of an annotation with the feature notation:
+      The covered text of an annotation can be accessed as a string expression and the type of 
+      an annotation can be accessed as an type expression.
+    </para>
+    <para>
       The covered text of an annotation can be referred to with "coveredText" or "ct". 
       The latter one is an abbreviation and returns the covered text of an annotation
       only if the type of the annotation does not define a feature with the name "ct". 
@@ -324,5 +398,10 @@ FeatureAssignmentExpression -> FeatureEx
       covered text "A".
       <programlisting><![CDATA[W.ct == "A" {-> TypeA};]]></programlisting>
     </para>
+    <para>
+      The type of an annotation can be referred to with "type". 
+      The following example creates an annotation of the type TypeA for each pair of ANY annotation.
+      <programlisting><![CDATA[(a1:ANY a2:ANY){a1.type == a2.type -> TypeA};]]></programlisting>
+    </para>
   </section>
 </section>
\ No newline at end of file

Modified: uima/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.language.xml
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.language.xml?rev=1870098&r1=1870097&r2=1870098&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.language.xml (original)
+++ uima/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.language.xml Thu Nov 21 17:07:25 2019
@@ -898,6 +898,12 @@ Document{->MARKTABLE(PresidentOfUSA, 1,
 WORDTABLE presidentsOfUSA = "" + package + "presidentsOfUSA.csv";
 ]]></programlisting>
       </para>
+      <para>
+        By default, whitespaces are removed by the activated parameter <quote>dictRemoveWS</quote> 
+        for WORDLIST and WORDTABLE when the dictionary is loaded. In the special case when whitespace are relevant, e.g., 
+        specific patterns of whitespaces need to be detected by the dictionary lookup, 
+        then the analysis engine needs to be configured differently. 
+      </para>
     </section>
   </section>
   <section id="ugr.tools.ruta.language.regexprule">

Modified: uima/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.overview.xml
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.overview.xml?rev=1870098&r1=1870097&r2=1870098&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.overview.xml (original)
+++ uima/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.overview.xml Thu Nov 21 17:07:25 2019
@@ -1317,6 +1317,7 @@ Document{-> EXEC(MyAnalysisEngine, {MyTy
           <title>dictRemoveWS</title>
           <para>
             If this parameter is set to true, then whitespaces are removed when dictionaries are loaded.
+            The default is set to "true".
           </para>
         </section>
         <section id="ugr.tools.ruta.ae.basic.parameter.csvSeparator">
@@ -1352,7 +1353,7 @@ Document{-> EXEC(MyAnalysisEngine, {MyTy
       <title>Annotation Writer</title>
       <para>
         This Analysis Engine can be utilized to write the covered text of annotations in a text file, whereas each covered text is put into a new line.
-        If the Analyis engine, for example, is configured for the type <quote>uima.example.Person</quote>, then all covered texts of all Person annotations are stored
+        If the Analysis engine, for example, is configured for the type <quote>uima.example.Person</quote>, then all covered texts of all Person annotations are stored
         in a text file, one person in each line.
         A descriptor file for this Analysis Engine is located in the folder <quote>descriptor/utils</quote> of a UIMA Ruta project.
       </para>
@@ -1552,7 +1553,7 @@ Document{-> EXEC(MyAnalysisEngine, {MyTy
             This boolean parameter determines if the converter should skip whitespaces. 
             Html documents often contains whitespaces for indentation and formatting, 
             which should not be reproduced in the converted plain text document.
-            If the parameter is set to false, then the whitespces are not removed. 
+            If the parameter is set to false, then the whitespaces are not removed. 
             This behavior is useful, if not Html documents are converted, but XMl files.
             The default value is true.
           </para>
@@ -1576,7 +1577,7 @@ Document{-> EXEC(MyAnalysisEngine, {MyTy
           <title>gapInducingTags</title>
           <para>
             This string array parameter sets the names of the html tags that create additional text in the
-   output view. The acutal string of the gap is defined by the parameter <quote>gapText</quote>.
+   output view. The actual string of the gap is defined by the parameter <quote>gapText</quote>.
           </para>
         </section>
         <section id="ugr.tools.ruta.ae.htmlconverter.parameter.gapText">
@@ -1597,7 +1598,7 @@ Document{-> EXEC(MyAnalysisEngine, {MyTy
       <title>Style Map Creator</title>
       <para>
         This Analysis Engine can be utilized to create style map information, which is needed by the Modifier Analysis Engine in order to create
-        highlightings for some annotations.
+        highlighting for some annotations.
         Style map information can be created using the <link linkend='ugr.tools.ruta.language.actions.color'>COLOR</link> action.
         A descriptor file for this Analysis Engine is located in the folder <quote>descriptor/utils</quote> of a UIMA Ruta project.
       </para>

Modified: uima/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.workbench.explain_perspective.xml
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.workbench.explain_perspective.xml?rev=1870098&r1=1870097&r2=1870098&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.workbench.explain_perspective.xml (original)
+++ uima/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.workbench.explain_perspective.xml Thu Nov 21 17:07:25 2019
@@ -260,7 +260,7 @@
       of this inlined rule.
     </para>
     <para>
-      This view is not by default included in the perspective, but need to be added manually, 
+      This view is not by default included in the perspective, but needs to be added manually, 
       e.g., by using the Quick Access near the perspectives.
     </para>