Author: pkluegl
Date: Thu Jan 10 15:56:54 2019
New Revision: 1850950

URL: http://svn.apache.org/viewvc?rev=1850950&view=rev
Log:
UIMA-5952: added parameter

Modified:
    uima/ruta/trunk/RELEASE_NOTES.html
    
uima/ruta/trunk/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaParser.g
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaConstants.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaScriptFactory.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/descriptor/RutaDescriptorFactory.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/engine/RutaEngine.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/NumberFeatureExpression.java
    
uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/descriptor/GenerateDescriptorTest.java
    uima/ruta/trunk/ruta-docbook/src/docbook/tools.ruta.overview.xml

Modified: uima/ruta/trunk/RELEASE_NOTES.html
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/RELEASE_NOTES.html?rev=1850950&r1=1850949&r2=1850950&view=diff
==============================================================================
--- uima/ruta/trunk/RELEASE_NOTES.html (original)
+++ uima/ruta/trunk/RELEASE_NOTES.html Thu Jan 10 15:56:54 2019
@@ -58,6 +58,7 @@
     <li>New configuration parameter 'inferenceVisitors'.</li>
     <li>New configuration parameter 'maxRuleMatches'.</li>
     <li>New configuration parameter 'maxRuleElementMatches'.</li>
+    <li>New configuration parameter 'rulesScriptName'.</li>
     <li>Inlined rules as condition are only evaluated if the rule element 
match was successful.</li>
     <li>String features with allowed values are supported.</li>
     <li>PlainTextAnnotator supports vertical tabs.</li>

Modified: 
uima/ruta/trunk/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaParser.g
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaParser.g?rev=1850950&r1=1850949&r2=1850950&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaParser.g
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaParser.g
 Thu Jan 10 15:56:54 2019
@@ -165,23 +165,23 @@ public void setExternalFactory(RutaExter
            }
            int line = e.line;
            String text = e.token.getText();
-       
+           String name = StringUtils.isBlank(moduleName) ? "unknown script" : 
moduleName;
            if (e instanceof NoViableAltException) {
              NoViableAltException nvae = (NoViableAltException) e;
-             String msg = "Error in "+moduleName+",  line " + nvae.line + ", 
\"" + text + "\": found no viable alternative";
+             String msg = "Error in "+name+",  line " + nvae.line + ", \"" + 
text + "\": found no viable alternative";
              emitErrorMessage(msg);
            } else if (e instanceof MismatchedTokenException) {
              MismatchedTokenException mte = (MismatchedTokenException) e;
              int expectedInt = mte.expecting;
              String stringExpected = expectedInt < 0 ? "'none'" : 
getTokenNames()[expectedInt];
-             String msg = "Error in "+moduleName+", line " + line + ", \"" + 
text + "\": expected " + stringExpected
+             String msg = "Error in "+name+", line " + line + ", \"" + text + 
"\": expected " + stringExpected
                      + ", but found " + stringFound;
              emitErrorMessage(msg);
            } else if (e instanceof MissingTokenException) {
              MissingTokenException mte = (MissingTokenException) e;
              int missingType = mte.getMissingType();
              String stringMissing = getTokenNames()[missingType];
-             String msg = "Error in "+moduleName+",  line " + line + ", \"" + 
text + "\": missing " + stringMissing
+             String msg = "Error in "+name+",  line " + line + ", \"" + text + 
"\": missing " + stringMissing
                     + ", but found " + stringFound;
              emitErrorMessage(msg);
            } else {
@@ -249,14 +249,23 @@ public void setExternalFactory(RutaExter
          }
          String resolvedType = name;
          if (!name.contains(".")) {
-           resolvedType = namespace + "." + moduleName + "." + name;
+           if(StringUtils.isBlank(moduleName)) {
+             resolvedType = namespace + "." + name;
+           } else {
+             resolvedType = namespace + "." + moduleName + "." + name;
+           }
          }
           parent.getEnvironment().declareType(resolvedType);
          if(descInfo != null) {
                  name = parent.getNamespace() + "." + name.trim();
                  String descriptionString = null;
                  if(StringUtils.isBlank(namespace)) {
-                         descriptionString = "Type defined in " + moduleName;
+                       if(StringUtils.isBlank(moduleName)) {
+                               descriptionString = "Type defined in unknown 
script.";
+                       } else {
+                               descriptionString = "Type defined in " + 
moduleName;
+                       }
+                         
                          } else {
                          descriptionString = "Type defined in " + 
parent.getNamespace();
                  }

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaConstants.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaConstants.java?rev=1850950&r1=1850949&r2=1850950&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaConstants.java 
(original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaConstants.java 
Thu Jan 10 15:56:54 2019
@@ -20,6 +20,8 @@ package org.apache.uima.ruta;
 
 public class RutaConstants {
 
+  public static final String ANONYMOUS_SCRIPT = "Anonymous";
+
   public static final String RUTA_VARIABLE_ANNOTATION = "ANNOTATION";
 
   public static final String RUTA_VARIABLE_ANNOTATION_LIST = "ANNOTATIONLIST";

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaScriptFactory.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaScriptFactory.java?rev=1850950&r1=1850949&r2=1850950&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaScriptFactory.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaScriptFactory.java
 Thu Jan 10 15:56:54 2019
@@ -25,6 +25,7 @@ import java.util.Map;
 import java.util.TreeMap;
 
 import org.antlr.runtime.Token;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.uima.UimaContext;
 import org.apache.uima.cas.CAS;
 import org.apache.uima.ruta.action.AbstractRutaAction;
@@ -117,10 +118,8 @@ public class RutaScriptFactory {
   }
 
   public RutaScriptBlock createRootScriptBlock(String module, String pack) {
-    String defaultNamespace = module;
-    if (pack != null) {
-      defaultNamespace = pack + "." + module;
-    }
+    String defaultNamespace = getDefaultNamespace(module, pack);
+
     RutaScriptBlock result = createScriptBlock(module, null, null, null, 
defaultNamespace);
     List<RuleElement> ruleElements = new ArrayList<RuleElement>();
     RuleElementIsolator container = new RuleElementIsolator();
@@ -136,6 +135,20 @@ public class RutaScriptFactory {
     return result;
   }
 
+  private String getDefaultNamespace(String module, String pack) {
+    String defaultNamespace = module;
+    if (StringUtils.isBlank(module) && StringUtils.isBlank(pack)) {
+      defaultNamespace = "";
+    } else if (StringUtils.isBlank(module) && StringUtils.isBlank(pack)) {
+      defaultNamespace = pack + "." + module;
+    } else if (!StringUtils.isBlank(module)) {
+      defaultNamespace = module;
+    } else if (!StringUtils.isBlank(pack)) {
+      defaultNamespace = pack;
+    }
+    return defaultNamespace;
+  }
+
   public RutaBlock createForEachBlock(Token varToken, IBooleanExpression 
direction,
           RutaRuleElement ruleElement, List<RutaStatement> body, RutaBlock 
parent) {
 

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/descriptor/RutaDescriptorFactory.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/descriptor/RutaDescriptorFactory.java?rev=1850950&r1=1850949&r2=1850950&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/descriptor/RutaDescriptorFactory.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/descriptor/RutaDescriptorFactory.java
 Thu Jan 10 15:56:54 2019
@@ -39,6 +39,7 @@ import org.apache.uima.resource.Resource
 import org.apache.uima.resource.ResourceManager;
 import org.apache.uima.resource.impl.ResourceManager_impl;
 import org.apache.uima.resource.metadata.TypeSystemDescription;
+import org.apache.uima.ruta.RutaConstants;
 import org.apache.uima.ruta.RutaScriptFactory;
 import org.apache.uima.ruta.action.ActionFactory;
 import org.apache.uima.ruta.condition.ConditionFactory;
@@ -52,18 +53,16 @@ import org.apache.uima.util.InvalidXMLEx
 
 public class RutaDescriptorFactory {
 
-  // public static final String ANONYMOUS = "Anonymous";
-
   private URL defaultTypeSystem;
 
   private URL defaultEngine;
 
   public RutaDescriptorFactory() {
     super();
-    this.defaultEngine = 
RutaDescriptorFactory.class.getClassLoader().getResource(
-            "org/apache/uima/ruta/engine/BasicEngine.xml");
-    this.defaultTypeSystem = 
RutaDescriptorFactory.class.getClassLoader().getResource(
-            "org/apache/uima/ruta/engine/BasicTypeSystem.xml");
+    this.defaultEngine = RutaDescriptorFactory.class.getClassLoader()
+            .getResource("org/apache/uima/ruta/engine/BasicEngine.xml");
+    this.defaultTypeSystem = RutaDescriptorFactory.class.getClassLoader()
+            .getResource("org/apache/uima/ruta/engine/BasicTypeSystem.xml");
   }
 
   public RutaDescriptorFactory(String defaultTypeSystem, String defaultEngine)
@@ -86,8 +85,8 @@ public class RutaDescriptorFactory {
 
     RutaDescriptorBuilder builder = new 
RutaDescriptorBuilder(defaultTypeSystem, defaultEngine);
 
-    TypeSystemDescription typeSystemDescription = 
builder.createTypeSystemDescription(
-            descriptorInformation, typeSystemOutput, options, null);
+    TypeSystemDescription typeSystemDescription = builder
+            .createTypeSystemDescription(descriptorInformation, 
typeSystemOutput, options, null);
 
     return typeSystemDescription;
   }
@@ -132,19 +131,18 @@ public class RutaDescriptorFactory {
     RutaLexer lexer = new RutaLexer(st);
     CommonTokenStream tokens = new CommonTokenStream(lexer);
     RutaParser parser = new RutaParser(tokens);
-    
+
     RutaDescriptorInformation descInfo = new RutaDescriptorInformation();
-    
-    
+
     parser.setDescriptorInformation(descInfo);
-    
+
     ExpressionFactory expressionFactory = new ExpressionFactory();
     ActionFactory actionFactory = new ActionFactory();
     ConditionFactory conditionFactory = new ConditionFactory();
     RutaScriptFactory scriptFactory = new RutaScriptFactory(expressionFactory);
     scriptFactory.setContext(null);
     ResourceManager rm = getResourceManager(options);
-    
+
     parser.setScriptFactory(scriptFactory);
     parser.setExpressionFactory(expressionFactory);
     parser.setActionFactory(actionFactory);
@@ -153,7 +151,7 @@ public class RutaDescriptorFactory {
     parser.setContext(null);
     parser.setResourcePaths(new String[0]);
     parser.setResourceManager(rm);
-    
+
     String name = scriptFile.getName();
     int lastIndexOf = name.lastIndexOf(RutaEngine.SCRIPT_FILE_EXTENSION);
     if (lastIndexOf != -1) {
@@ -164,25 +162,30 @@ public class RutaDescriptorFactory {
     return descInfo;
   }
 
-  public RutaDescriptorInformation parseDescriptorInformation(String script) 
throws IOException,
-          RecognitionException {
+  public RutaDescriptorInformation parseDescriptorInformation(String script)
+          throws IOException, RecognitionException {
     return parseDescriptorInformation(script, new RutaBuildOptions());
   }
 
-  public RutaDescriptorInformation parseDescriptorInformation(String script,
+  public RutaDescriptorInformation parseDescriptorInformation(String rules,
           RutaBuildOptions options) throws IOException, RecognitionException {
-    CharStream st = new ANTLRStringStream(script);
+    return parseDescriptorInformation(rules, RutaConstants.ANONYMOUS_SCRIPT, 
options);
+  }
+
+  public RutaDescriptorInformation parseDescriptorInformation(String rules, 
String rulesScriptName,
+          RutaBuildOptions options) throws IOException, RecognitionException {
+    CharStream st = new ANTLRStringStream(rules);
     RutaLexer lexer = new RutaLexer(st);
     CommonTokenStream tokens = new CommonTokenStream(lexer);
     RutaParser parser = new RutaParser(tokens);
     RutaDescriptorInformation descInfo = new RutaDescriptorInformation();
     parser.setDescriptorInformation(descInfo);
-   
+
     ExpressionFactory expressionFactory = new ExpressionFactory();
     ActionFactory actionFactory = new ActionFactory();
     ConditionFactory conditionFactory = new ConditionFactory();
     RutaScriptFactory scriptFactory = new RutaScriptFactory(expressionFactory);
-    
+
     parser.setContext(null);
     parser.setScriptFactory(scriptFactory);
     parser.setExpressionFactory(expressionFactory);
@@ -192,10 +195,9 @@ public class RutaDescriptorFactory {
     parser.setResourcePaths(new String[0]);
     ResourceManager rm = getResourceManager(options);
     parser.setResourceManager(rm);
-    String name = "Anonymous";
-    descInfo.setScriptName(name);
-    parser.file_input(name);
-    descInfo.setRules(script);
+    descInfo.setScriptName(rulesScriptName);
+    parser.file_input(rulesScriptName);
+    descInfo.setRules(rules);
     return descInfo;
   }
 

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/engine/RutaEngine.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/engine/RutaEngine.java?rev=1850950&r1=1850949&r2=1850950&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/engine/RutaEngine.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/engine/RutaEngine.java
 Thu Jan 10 15:56:54 2019
@@ -61,6 +61,7 @@ import org.apache.uima.jcas.JCas;
 import org.apache.uima.resource.ResourceInitializationException;
 import org.apache.uima.resource.ResourceManager;
 import org.apache.uima.ruta.FilterManager;
+import org.apache.uima.ruta.RutaConstants;
 import org.apache.uima.ruta.RutaEnvironment;
 import org.apache.uima.ruta.RutaModule;
 import org.apache.uima.ruta.RutaScriptFactory;
@@ -113,6 +114,14 @@ public class RutaEngine extends JCasAnno
   private String rules;
 
   /**
+   * This parameter specifies the name of the non-existing script if the 
parameter 'rules' is used.
+   */
+  public static final String PARAM_RULES_SCRIPT_NAME = "rulesScriptName";
+
+  @ConfigurationParameter(name = PARAM_RULES_SCRIPT_NAME, mandatory = true, 
defaultValue = RutaConstants.ANONYMOUS_SCRIPT)
+  private String rulesScriptName;
+
+  /**
    * Load script in Java notation, with "{@code .}" as package separator and 
no extension. File
    * needs to be located in the path specified below with ending {@code .ruta}.
    */
@@ -1121,7 +1130,7 @@ public class RutaEngine extends JCasAnno
     RutaLexer lexer = new RutaLexer(st);
     CommonTokenStream tokens = new CommonTokenStream(lexer);
     RutaParser parser = createParser(tokens);
-    RutaModule script = parser.file_input("Anonymous");
+    RutaModule script = parser.file_input(rulesScriptName);
     return script;
   }
 

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/NumberFeatureExpression.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/NumberFeatureExpression.java?rev=1850950&r1=1850949&r2=1850950&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/NumberFeatureExpression.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/NumberFeatureExpression.java
 Thu Jan 10 15:56:54 2019
@@ -71,16 +71,16 @@ public class NumberFeatureExpression ext
             false, context, stream);
     if (!featureStructures.isEmpty()) {
       Feature feature = this.fe.getFeature(context, stream);
-      Type range = feature.getRange();
       FeatureStructure next = featureStructures.iterator().next();
-//      if (next instanceof AnnotationFS && 
!next.getType().equals(annotation.getType())) {
-//        feature = this.fe.getFeature(new MatchContext((AnnotationFS) next, 
context.getElement(),
-//                context.getRuleMatch(), context.getDirection()), stream);
-//      }
       if (feature instanceof LazyFeature) {
         LazyFeature lazyFeature = (LazyFeature) feature;
         feature = lazyFeature.initialize(next);
       }
+      Type range = feature.getRange();
+//      if (next instanceof AnnotationFS && 
!next.getType().equals(annotation.getType())) {
+//        feature = this.fe.getFeature(new MatchContext((AnnotationFS) next, 
context.getElement(),
+//                context.getRuleMatch(), context.getDirection()), stream);
+//      }
       if (CAS.TYPE_NAME_BYTE.equals(range.getName())) {
         result = next.getByteValue(feature);
       } else if (CAS.TYPE_NAME_DOUBLE.equals(range.getName())) {

Modified: 
uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/descriptor/GenerateDescriptorTest.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/descriptor/GenerateDescriptorTest.java?rev=1850950&r1=1850949&r2=1850950&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/descriptor/GenerateDescriptorTest.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/descriptor/GenerateDescriptorTest.java
 Thu Jan 10 15:56:54 2019
@@ -19,10 +19,6 @@
 
 package org.apache.uima.ruta.descriptor;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
 import java.io.IOException;
 import java.net.URISyntaxException;
 import java.net.URL;
@@ -47,10 +43,10 @@ import org.apache.uima.resource.metadata
 import org.apache.uima.ruta.engine.HtmlAnnotator;
 import org.apache.uima.ruta.engine.RutaEngine;
 import org.apache.uima.util.InvalidXMLException;
+import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-
 public class GenerateDescriptorTest {
 
   private static URL basicAEUrl;
@@ -59,29 +55,34 @@ public class GenerateDescriptorTest {
 
   @BeforeClass
   public static void setUpClass() {
-    basicAEUrl = 
GenerateDescriptorTest.class.getClassLoader().getResource("BasicEngine.xml");
-    if (basicAEUrl == null) {
-      basicAEUrl = HtmlAnnotator.class.getClassLoader().getResource(
-              "org/apache/uima/ruta/engine/BasicEngine.xml");
+
+    GenerateDescriptorTest.basicAEUrl = 
GenerateDescriptorTest.class.getClassLoader()
+            .getResource("BasicEngine.xml");
+    if (GenerateDescriptorTest.basicAEUrl == null) {
+      GenerateDescriptorTest.basicAEUrl = HtmlAnnotator.class.getClassLoader()
+              .getResource("org/apache/uima/ruta/engine/BasicEngine.xml");
     }
 
-    basicTSUrl = 
GenerateDescriptorTest.class.getClassLoader().getResource("BasicTypeSystem.xml");
-    if (basicTSUrl == null) {
-      basicTSUrl = HtmlAnnotator.class.getClassLoader().getResource(
-              "org/apache/uima/ruta/engine/BasicTypeSystem.xml");
+    GenerateDescriptorTest.basicTSUrl = 
GenerateDescriptorTest.class.getClassLoader()
+            .getResource("BasicTypeSystem.xml");
+    if (GenerateDescriptorTest.basicTSUrl == null) {
+      GenerateDescriptorTest.basicTSUrl = HtmlAnnotator.class.getClassLoader()
+              .getResource("org/apache/uima/ruta/engine/BasicTypeSystem.xml");
     }
   }
 
   @Test
-  public void testCreateAnalysisEngineDescription() throws 
InvalidXMLException, IOException,
-          RecognitionException, URISyntaxException {
+  public void testCreateAnalysisEngineDescription()
+          throws InvalidXMLException, IOException, RecognitionException, 
URISyntaxException {
+
     String script = "";
     script += "PACKAGE test.package;\n";
     script += "ENGINE org.apache.uima.ruta.engine.HtmlAnnotator;\n";
     script += "UIMAFIT org.apache.uima.ruta.engine.PlainTextAnnotator;\n";
     script += "SCRIPT org.apache.uiima.ruta.Additional;\n";
 
-    RutaDescriptorFactory rdf = new RutaDescriptorFactory(basicTSUrl, 
basicAEUrl);
+    RutaDescriptorFactory rdf = new 
RutaDescriptorFactory(GenerateDescriptorTest.basicTSUrl,
+            GenerateDescriptorTest.basicAEUrl);
     RutaDescriptorInformation descriptorInformation = 
rdf.parseDescriptorInformation(script);
     RutaBuildOptions options = new RutaBuildOptions();
     String typeSystemOutput = 
"target/temp/testCreateAnalysisEngineDescription_TypeSystem.xml";
@@ -94,26 +95,31 @@ public class GenerateDescriptorTest {
 
     String mainScript = (String) 
cps.getParameterValue(RutaEngine.PARAM_MAIN_SCRIPT);
     String rules = (String) cps.getParameterValue(RutaEngine.PARAM_RULES);
-    assertNull("mainScript param should be null", mainScript);
-    assertNotNull("rules param should not null", rules);
-    
-    String[] additionalEngines = (String[]) 
cps.getParameterValue(RutaEngine.PARAM_ADDITIONAL_ENGINES);
-    assertNotNull(additionalEngines);
-    assertEquals("org.apache.uima.ruta.engine.HtmlAnnotator", 
additionalEngines[0]);
-    
-    String[] additionalUimafitEngines = (String[]) 
cps.getParameterValue(RutaEngine.PARAM_ADDITIONAL_UIMAFIT_ENGINES);
-    assertNotNull(additionalUimafitEngines);
-    assertEquals("org.apache.uima.ruta.engine.PlainTextAnnotator", 
additionalUimafitEngines[0]);
-    
-    String[] additionalScripts = (String[]) 
cps.getParameterValue(RutaEngine.PARAM_ADDITIONAL_SCRIPTS);
-    assertNotNull(additionalScripts);
-    assertEquals("org.apache.uiima.ruta.Additional", additionalScripts[0]);
-    
+    Assert.assertNull("mainScript param should be null", mainScript);
+    Assert.assertNotNull("rules param should not null", rules);
+
+    String[] additionalEngines = (String[]) cps
+            .getParameterValue(RutaEngine.PARAM_ADDITIONAL_ENGINES);
+    Assert.assertNotNull(additionalEngines);
+    Assert.assertEquals("org.apache.uima.ruta.engine.HtmlAnnotator", 
additionalEngines[0]);
+
+    String[] additionalUimafitEngines = (String[]) cps
+            .getParameterValue(RutaEngine.PARAM_ADDITIONAL_UIMAFIT_ENGINES);
+    Assert.assertNotNull(additionalUimafitEngines);
+    Assert.assertEquals("org.apache.uima.ruta.engine.PlainTextAnnotator",
+            additionalUimafitEngines[0]);
+
+    String[] additionalScripts = (String[]) cps
+            .getParameterValue(RutaEngine.PARAM_ADDITIONAL_SCRIPTS);
+    Assert.assertNotNull(additionalScripts);
+    Assert.assertEquals("org.apache.uiima.ruta.Additional", 
additionalScripts[0]);
+
   }
 
   @Test
   public void testCreateTypeSystemDescription() throws URISyntaxException, 
IOException,
           RecognitionException, InvalidXMLException, 
ResourceInitializationException {
+
     String script = "";
     script += "PACKAGE test.package;\n";
     script += "TYPESYSTEM org.apache.uima.ruta.engine.HtmlTypeSystem;\n";
@@ -124,7 +130,8 @@ public class GenerateDescriptorTest {
     script += "DECLARE InnerType;\n";
     script += "}\n";
 
-    RutaDescriptorFactory rdf = new RutaDescriptorFactory(basicTSUrl, 
basicAEUrl);
+    RutaDescriptorFactory rdf = new 
RutaDescriptorFactory(GenerateDescriptorTest.basicTSUrl,
+            GenerateDescriptorTest.basicAEUrl);
     RutaDescriptorInformation descriptorInformation = 
rdf.parseDescriptorInformation(script);
     RutaBuildOptions options = new RutaBuildOptions();
     String typeSystemOutput = 
"target/temp/testCreateTypeSystemDescription_TypeSystem.xml";
@@ -135,67 +142,97 @@ public class GenerateDescriptorTest {
     tsd.resolveImports(rm);
 
     TypeDescription tagType = 
tsd.getType("org.apache.uima.ruta.type.html.TAG");
-    assertNotNull(tagType);
+    Assert.assertNotNull(tagType);
 
     TypeDescription simpleType = 
tsd.getType("test.package.Anonymous.SimpleType");
-    assertNotNull(simpleType);
-    assertEquals("uima.tcas.Annotation", simpleType.getSupertypeName());
+    Assert.assertNotNull(simpleType);
+    Assert.assertEquals("uima.tcas.Annotation", simpleType.getSupertypeName());
 
     TypeDescription complexType = 
tsd.getType("test.package.Anonymous.ComplexType");
-    assertNotNull(complexType);
-    assertEquals("Type defined in test.package.Anonymous", 
complexType.getDescription());
-    assertEquals("test.package.Anonymous.SimpleType", 
complexType.getSupertypeName());
+    Assert.assertNotNull(complexType);
+    Assert.assertEquals("Type defined in test.package.Anonymous", 
complexType.getDescription());
+    Assert.assertEquals("test.package.Anonymous.SimpleType", 
complexType.getSupertypeName());
     FeatureDescription[] features = complexType.getFeatures();
     Map<String, String> featureMap = new HashMap<>();
     featureMap.put("fs", "test.package.Anonymous.SimpleType");
     featureMap.put("s", "uima.cas.String");
     featureMap.put("b", "uima.cas.Boolean");
     featureMap.put("i", "uima.cas.Integer");
-    assertEquals(4, features.length);
+    Assert.assertEquals(4, features.length);
     for (FeatureDescription each : features) {
       String f = featureMap.get(each.getName());
-      assertNotNull(f);
+      Assert.assertNotNull(f);
     }
-    
+
     TypeDescription complexType2 = 
tsd.getType("test.package.Anonymous.ComplexType2");
-    assertNotNull(complexType2);
-    assertEquals("Type defined in test.package.Anonymous", 
complexType2.getDescription());
-    assertEquals("uima.tcas.Annotation", complexType2.getSupertypeName());
+    Assert.assertNotNull(complexType2);
+    Assert.assertEquals("Type defined in test.package.Anonymous", 
complexType2.getDescription());
+    Assert.assertEquals("uima.tcas.Annotation", 
complexType2.getSupertypeName());
     FeatureDescription[] features2 = complexType2.getFeatures();
     Map<String, String> featureMap2 = new HashMap<>();
     featureMap2.put("fs", "test.package.Anonymous.SimpleType");
     featureMap2.put("s", "uima.cas.String");
     featureMap2.put("b", "uima.cas.Boolean");
     featureMap2.put("i", "uima.cas.Integer");
-    assertEquals(4, features2.length);
+    Assert.assertEquals(4, features2.length);
     for (FeatureDescription each : features2) {
       String f = featureMap2.get(each.getName());
-      assertNotNull(f);
+      Assert.assertNotNull(f);
     }
 
     TypeDescription innerType = 
tsd.getType("test.package.Anonymous.sub.InnerType");
-    assertNotNull(innerType);
-    assertEquals("uima.tcas.Annotation", innerType.getSupertypeName());
+    Assert.assertNotNull(innerType);
+    Assert.assertEquals("uima.tcas.Annotation", innerType.getSupertypeName());
+
+  }
+
+  @Test
+  public void testRuleScriptName() throws URISyntaxException, IOException, 
RecognitionException,
+          InvalidXMLException, ResourceInitializationException {
+
+    String script = "";
+    script += "PACKAGE test.package;\n";
+    script += "DECLARE SimpleType;\n";
+
+    RutaDescriptorFactory rdf = new 
RutaDescriptorFactory(GenerateDescriptorTest.basicTSUrl,
+            GenerateDescriptorTest.basicAEUrl);
+    RutaBuildOptions options = new RutaBuildOptions();
+    RutaDescriptorInformation descriptorInformation = 
rdf.parseDescriptorInformation(script, null,
+            options);
+    String typeSystemOutput = "target/temp/testRuleScriptName_TypeSystem.xml";
+    ClassLoader classLoader = GenerateDescriptorTest.class.getClassLoader();
+    TypeSystemDescription tsd = 
rdf.createTypeSystemDescription(typeSystemOutput,
+            descriptorInformation, options, classLoader);
+    ResourceManager rm = new ResourceManager_impl(classLoader);
+    tsd.resolveImports(rm);
+
+    TypeDescription tagType = tsd.getType("test.package.SimpleType");
+    Assert.assertNotNull(tagType);
 
   }
 
   @Test
   public void testScriptOnly() throws Exception {
+
     String script = "DECLARE Type; CW{-> Type};";
-    
-    RutaDescriptorFactory rdf = new RutaDescriptorFactory(basicTSUrl, 
basicAEUrl);
+
+    RutaDescriptorFactory rdf = new 
RutaDescriptorFactory(GenerateDescriptorTest.basicTSUrl,
+            GenerateDescriptorTest.basicAEUrl);
     RutaDescriptorInformation descriptorInformation = 
rdf.parseDescriptorInformation(script);
     RutaBuildOptions options = new RutaBuildOptions();
-    Pair<AnalysisEngineDescription, TypeSystemDescription> descriptions = 
rdf.createDescriptions(null, null, descriptorInformation, options, null, null, 
null);
-    assertNotNull("Typesystem does not contain declaredtype!", 
descriptions.getValue().getType("Anonymous.Type"));
-    assertNotNull("AE typesystem does not contain declared type!", 
descriptions.getKey().getAnalysisEngineMetaData().getTypeSystem().getType("Anonymous.Type"));
+    Pair<AnalysisEngineDescription, TypeSystemDescription> descriptions = rdf
+            .createDescriptions(null, null, descriptorInformation, options, 
null, null, null);
+    Assert.assertNotNull("Typesystem does not contain declaredtype!",
+            descriptions.getValue().getType("Anonymous.Type"));
+    Assert.assertNotNull("AE typesystem does not contain declared type!", 
descriptions.getKey()
+            
.getAnalysisEngineMetaData().getTypeSystem().getType("Anonymous.Type"));
     AnalysisEngine ae = 
UIMAFramework.produceAnalysisEngine(descriptions.getKey());
     CAS cas = ae.newCAS();
     cas.setDocumentText("This is a test.");
     ae.process(cas);
     Type type = cas.getTypeSystem().getType("Anonymous.Type");
-    assertEquals(1, CasUtil.select(cas, type).size());
+    Assert.assertEquals(1, CasUtil.select(cas, type).size());
     cas.release();
   }
-  
+
 }

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=1850950&r1=1850949&r2=1850950&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 Jan 10 
15:56:54 2019
@@ -708,6 +708,14 @@ Document{-> EXEC(MyAnalysisEngine, {MyTy
                 </row>
                 <row>
                   <entry>
+                    <link 
linkend='ugr.tools.ruta.ae.basic.parameter.rules'>rulesScriptName</link>
+                  </entry>
+                  <entry>This parameter specifies the name of the non-existing 
script if the parameter 'rules' is used.
+                  </entry>
+                  <entry>Single String</entry>
+                </row>
+                <row>
+                  <entry>
                     <link 
linkend='ugr.tools.ruta.ae.basic.parameter.scriptEncoding'>scriptEncoding</link>
                   </entry>
                   <entry>Encoding of all UIMA Ruta script files.</entry>
@@ -1012,6 +1020,14 @@ Document{-> EXEC(MyAnalysisEngine, {MyTy
           If set, it replaces the content of file specified by the <link 
linkend='ugr.tools.ruta.ae.basic.parameter.mainScript'>mainScript</link> 
parameter.
           </para>
         </section>
+        <section id="ugr.tools.ruta.ae.basic.parameter.rulesScriptName">
+          <title>rulesScriptName</title>
+          <para>
+          This parameter specifies the name of the non-existing script if the 
<link linkend='ugr.tools.ruta.ae.basic.parameter.rules'>rules</link> parameter 
is used.
+          The default value is 'Anonymous'.
+          </para>
+        </section>
+    
         <section id="ugr.tools.ruta.ae.basic.parameter.scriptEncoding">
           <title>scriptEncoding</title>
           <para>


Reply via email to