You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by ap...@apache.org on 2014/01/09 05:31:59 UTC

svn commit: r1556714 - in /uima/ruta/trunk/ruta-core/src: main/antlr3/org/apache/uima/ruta/parser/RutaParser.g test/java/org/apache/uima/ruta/ImportStatementsTest.java test/resources/org/apache/uima/ruta/ImportStatementsTestImportStarFromTypeSystem.ruta

Author: apatry
Date: Thu Jan  9 04:31:59 2014
New Revision: 1556714

URL: http://svn.apache.org/r1556714
Log:
UIMA-3303 Add support to import all types from a typesystem using "IMPORT * FROM typesystem"

Added:
    uima/ruta/trunk/ruta-core/src/test/resources/org/apache/uima/ruta/ImportStatementsTestImportStarFromTypeSystem.ruta
Modified:
    uima/ruta/trunk/ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/RutaParser.g
    uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/ImportStatementsTest.java

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=1556714&r1=1556713&r2=1556714&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  9 04:31:59 2014
@@ -436,6 +436,7 @@ importStatement returns [RutaStatement s
 	| EngineString ns = dottedIdentifier2{addImportEngine($blockDeclaration::env, ns);} SEMI
 	| UimafitString ns = dottedIdentifier2{addImportUimafitEngine($blockDeclaration::env, ns);} SEMI
 	| ImportString type = dottedIdentifier (FromString ts = dottedIdentifier2)? (AsString alias = Identifier)? SEMI{importTypeFromTypeSystem($blockDeclaration::env, ts, type, alias.getText());}
+	| ImportString STAR FromString ts = dottedIdentifier2 SEMI{addImportTypeSystem($blockDeclaration::env, ts);}
 	;
 
 declaration returns [RutaStatement stmt = null]

Modified: uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/ImportStatementsTest.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/ImportStatementsTest.java?rev=1556714&r1=1556713&r2=1556714&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/ImportStatementsTest.java (original)
+++ uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/ImportStatementsTest.java Thu Jan  9 04:31:59 2014
@@ -110,6 +110,22 @@ public class ImportStatementsTest {
 
   }
 
+  @Test
+  public void testImportStarFromTypeSystem() throws Exception {
+    AnalysisEngine ae = createAE(NAMESPACE + "/" + NAME + "ImportStarFromTypeSystem", true);
+    try {
+      CAS cas = ae.newCAS();
+      cas.setDocumentText("First Second");
+      ae.process(cas);
+
+      assertEquals(Arrays.asList("First"), selectText(cas, "org.apache.uima.ruta.Type1"));
+      assertEquals(Arrays.asList("Second"), selectText(cas, "org.apache.uima.ruta.Type2"));
+    } finally {
+      ae.destroy();
+    }
+
+  }
+
   private List<String> selectText(CAS cas, String type) {
     List<String> values = new ArrayList<String>();
     for (AnnotationFS annotation : CasUtil.select(cas, cas.getTypeSystem().getType(type))) {

Added: uima/ruta/trunk/ruta-core/src/test/resources/org/apache/uima/ruta/ImportStatementsTestImportStarFromTypeSystem.ruta
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/test/resources/org/apache/uima/ruta/ImportStatementsTestImportStarFromTypeSystem.ruta?rev=1556714&view=auto
==============================================================================
--- uima/ruta/trunk/ruta-core/src/test/resources/org/apache/uima/ruta/ImportStatementsTestImportStarFromTypeSystem.ruta (added)
+++ uima/ruta/trunk/ruta-core/src/test/resources/org/apache/uima/ruta/ImportStatementsTestImportStarFromTypeSystem.ruta Thu Jan  9 04:31:59 2014
@@ -0,0 +1,6 @@
+PACKAGE org.apache.uima.ruta;
+
+IMPORT * FROM org.apache.uima.ruta.ImportStatementsTestTypeSystem;
+
+W{REGEXP("First") -> MARK(Type1)};
+W{REGEXP("Second") -> MARK(Type2)};
\ No newline at end of file