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 2012/05/25 18:26:55 UTC

svn commit: r1342714 [3/5] - in /uima/sandbox/trunk/TextMarker: uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/core/parser/ uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/formatter/ uimaj-ep-textmarker-ide/sr...

Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/formatter/TextMarkerFormattedPrinter.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/formatter/TextMarkerFormattedPrinter.java?rev=1342714&r1=1342713&r2=1342714&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/formatter/TextMarkerFormattedPrinter.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/formatter/TextMarkerFormattedPrinter.java Fri May 25 16:26:54 2012
@@ -452,11 +452,13 @@ public class TextMarkerFormattedPrinter 
   private void printStructureAction(TextMarkerAction a) {
     TextMarkerStructureAction tmca = (TextMarkerStructureAction) a;
     // structure
-    append(tmca.getStructure());
+    if (tmca.getStructure() != null) {
+      append(tmca.getStructure());
+    }
     append(COMMA);
     append(" ");
     // number expressions
-    List<Expression> indices = tmca.getIndices();
+    List<Expression> indices = tmca.getExpressions();
     if (indices != null) {
       traverseAstNodes(indices);
     }
@@ -515,12 +517,13 @@ public class TextMarkerFormattedPrinter 
       append(" ");
     }
     // structure
-
-    append(tmca.getStructure());
+    if (tmca.getStructure() != null) {
+      append(tmca.getStructure());
+    }
     append(COMMA);
     append(" ");
     // number expressions
-    List<Expression> indices = tmca.getIndices();
+    List<Expression> indices = tmca.getExpressions();
     if (indices != null) {
       traverseAstNodes(indices);
     }

Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/ActionFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/ActionFactory.java?rev=1342714&r1=1342713&r2=1342714&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/ActionFactory.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/ActionFactory.java Fri May 25 16:26:54 2012
@@ -91,32 +91,12 @@ public class ActionFactory extends Abstr
   }
 
   public static TextMarkerAction createStructureAction(Token type, Expression structure,
-          List indexes, List<Expression> left, List<Expression> right) {
-    int bounds[] = getBounds(type);
-    int nameStart = bounds[0];
-    int nameEnd = bounds[1];
-    List<Expression> numExprs = new ArrayList<Expression>();
-    Map<Expression, Expression> assignments = new LinkedHashMap<Expression, Expression>();
-    filterNullObjsAndSetBounds(indexes, bounds, numExprs);
-    if (left != null && right != null) {
-      Iterator<Expression> keysIt = left.iterator();
-      Iterator<Expression> valsIt = right.iterator();
-      Expression val = null;
-      while (keysIt.hasNext()) {
-        Expression key = keysIt.next();
-        if (!valsIt.hasNext()) {
-          break;
-        }
-        val = valsIt.next();
-        assignments.put(key, val);
-      }
-      if (val != null) {
-        bounds[1] = val.sourceEnd();
-      }
+          List<Expression> indexes, List<Expression> left, List<Expression> right) {
+    List<Expression> args = new ArrayList<Expression>();
+    if (indexes != null) {
+      args.addAll(indexes);
     }
-    return new TextMarkerStructureAction(bounds[0], bounds[1], numExprs,
-            ExpressionConstants.USER_EXPRESSION_START + type.getType(), type.getText(), nameStart,
-            nameEnd, assignments, structure);
+    return createStructureAction(type, args, left, right, structure);
   }
 
   /**
@@ -168,6 +148,7 @@ public class ActionFactory extends Abstr
     List<Expression> indexes = new ArrayList<Expression>();
     indexes.add(table);
     indexes.add(index);
+    indexes.add(structure);
     filterNullObjsAndSetBounds(indexes, bounds, numExprs);
     if (left != null && right != null) {
       Iterator<Expression> keysIt = left.iterator();
@@ -218,4 +199,34 @@ public class ActionFactory extends Abstr
     }
     return createAction(name, exprs);
   }
+
+  public static TextMarkerAction createStructureAction(Token name, List<Expression> args,
+          List<Expression> left, List<Expression> right, Expression structure) {
+    int bounds[] = getBounds(name);
+    int nameStart = bounds[0];
+    int nameEnd = bounds[1];
+    List<Expression> numExprs = new ArrayList<Expression>();
+    Map<Expression, Expression> assignments = new LinkedHashMap<Expression, Expression>();
+    filterNullObjsAndSetBounds(args, bounds, numExprs);
+    if (left != null && right != null) {
+      Iterator<Expression> keysIt = left.iterator();
+      Iterator<Expression> valsIt = right.iterator();
+      Expression val = null;
+      while (keysIt.hasNext()) {
+        Expression key = keysIt.next();
+        if (!valsIt.hasNext()) {
+          break;
+        }
+        val = valsIt.next();
+        assignments.put(key, val);
+      }
+      if (val != null) {
+        bounds[1] = val.sourceEnd();
+      }
+    }
+    return new TextMarkerStructureAction(bounds[0], bounds[1], numExprs,
+            ExpressionConstants.USER_EXPRESSION_START + name.getType(), name.getText(), nameStart,
+            nameEnd, assignments, structure);
+  }
+
 }

Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerStructureAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerStructureAction.java?rev=1342714&r1=1342713&r2=1342714&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerStructureAction.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerStructureAction.java Fri May 25 16:26:54 2012
@@ -23,6 +23,7 @@ import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 
 import org.eclipse.dltk.ast.ASTVisitor;
 import org.eclipse.dltk.ast.expressions.Expression;
@@ -32,24 +33,23 @@ public class TextMarkerStructureAction e
 
   private Map<Expression, Expression> assignments;
 
-  public TextMarkerStructureAction(int start, int end, List<Expression> indexExprs, int kind,
+  public TextMarkerStructureAction(int start, int end, List<Expression> exprs, int kind,
           String name, int nameStart, int nameEnd, Map<Expression, Expression> assignments,
           Expression structure) {
-    super(start, end, indexExprs, kind, name, nameStart, nameEnd);
-    this.structure = structure;
+    super(start, end, exprs, kind, name, nameStart, nameEnd);
     this.assignments = assignments;
+    this.structure = structure;
   }
 
   @Override
   public void traverse(ASTVisitor visitor) throws Exception {
     if (visitor.visit(this)) {
-      structure.traverse(visitor);
       for (Expression e : super.exprs) {
         e.traverse(visitor);
       }
-      Iterator it = assignments.entrySet().iterator();
+      Iterator<Entry<Expression, Expression>> it = assignments.entrySet().iterator();
       while (it.hasNext()) {
-        Map.Entry pairs = (Map.Entry) it.next();
+        Map.Entry<Expression, Expression> pairs = it.next();
         if (pairs.getKey() == null || pairs.getValue() == null) {
           break;
         }
@@ -60,9 +60,8 @@ public class TextMarkerStructureAction e
   }
 
   @Override
-  public List getChilds() {
-    List l = new ArrayList<Expression>();
-    l.add(structure);
+  public List<Expression> getChilds() {
+    List<Expression> l = new ArrayList<Expression>();
     l.addAll(super.getChilds());
     l.addAll(assignments.keySet());
     l.addAll(assignments.values());
@@ -77,7 +76,7 @@ public class TextMarkerStructureAction e
     return structure;
   }
 
-  public List<Expression> getIndices() {
+  public List<Expression> getExpressions() {
     return super.exprs;
   }
 }

Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerVarRefChecker.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerVarRefChecker.java?rev=1342714&r1=1342713&r2=1342714&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerVarRefChecker.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerVarRefChecker.java Fri May 25 16:26:54 2012
@@ -221,8 +221,11 @@ public class TextMarkerVarRefChecker imp
         if (s instanceof TextMarkerStructureAction) {
           TextMarkerStructureAction sa = (TextMarkerStructureAction) s;
           Expression struct = sa.getStructure();
-          String structure = currentFile.getSource().substring(struct.sourceStart(),
-                  struct.sourceEnd());
+          String structure = null;
+          if (struct != null) {
+            structure = currentFile.getSource().substring(struct.sourceStart(),
+                    struct.sourceEnd());
+          }
           Map<Expression, Expression> assignments = sa.getAssignments();
           // hotfix... correct name in ast
           String action = currentFile.getSource().substring(sa.getNameStart(), sa.getNameEnd());
@@ -282,7 +285,7 @@ public class TextMarkerVarRefChecker imp
 
     private boolean findFeature(String structure, String feat) {
       boolean featureFound = false;
-      if (description == null) {
+      if (description == null || structure == null) {
         return featureFound;
       }
       TypeDescription[] descriptions = description.getTypes();

Modified: uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/ActionFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/ActionFactory.java?rev=1342714&r1=1342713&r2=1342714&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/ActionFactory.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/ActionFactory.java Fri May 25 16:26:54 2012
@@ -175,8 +175,8 @@ public class ActionFactory {
 
   public static AbstractTextMarkerAction createMarkTableAction(TypeExpression structure,
           NumberExpression index, WordTableExpression table,
-          Map<StringExpression, NumberExpression> map, TextMarkerBlock env) {
-    return new MarkTableAction(structure, index, table, map);
+          Map<StringExpression, NumberExpression> map, BooleanExpression ignoreCase, NumberExpression ignoreLength, StringExpression ignoreChar, NumberExpression maxIgnoreChar, TextMarkerBlock env) {
+    return new MarkTableAction(structure, index, table, map, ignoreCase, ignoreLength, ignoreChar, maxIgnoreChar);
   }
 
   public static AbstractTextMarkerAction createMergeAction(BooleanExpression union, Token target,

Modified: uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/MarkTableAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/MarkTableAction.java?rev=1342714&r1=1342713&r2=1342714&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/MarkTableAction.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/action/MarkTableAction.java Fri May 25 16:26:54 2012
@@ -33,6 +33,7 @@ import org.apache.uima.jcas.tcas.Annotat
 import org.apache.uima.textmarker.TextMarkerBlock;
 import org.apache.uima.textmarker.TextMarkerStream;
 import org.apache.uima.textmarker.UIMAConstants;
+import org.apache.uima.textmarker.expression.bool.BooleanExpression;
 import org.apache.uima.textmarker.expression.number.NumberExpression;
 import org.apache.uima.textmarker.expression.resource.WordTableExpression;
 import org.apache.uima.textmarker.expression.string.StringExpression;
@@ -52,14 +53,26 @@ public class MarkTableAction extends Abs
   private final Map<StringExpression, NumberExpression> featureMap;
 
   private final NumberExpression indexExpr;
+  
+  private final BooleanExpression ignoreCase;
+
+  private final NumberExpression ignoreLength;
+
+  private final StringExpression ignoreChar;
+
+  private final NumberExpression maxIgnoreChar;
 
   public MarkTableAction(TypeExpression typeExpr, NumberExpression indexExpr,
-          WordTableExpression tableExpr, Map<StringExpression, NumberExpression> featureMap) {
+          WordTableExpression tableExpr, Map<StringExpression, NumberExpression> featureMap, BooleanExpression ignoreCase, NumberExpression ignoreLength, StringExpression ignoreChar, NumberExpression maxIgnoreChar) {
     super();
     this.typeExpr = typeExpr;
     this.indexExpr = indexExpr;
     this.tableExpr = tableExpr;
     this.featureMap = featureMap;
+    this.ignoreCase = ignoreCase;
+    this.ignoreLength = ignoreLength;
+    this.ignoreChar = ignoreChar;
+    this.maxIgnoreChar = maxIgnoreChar;
   }
 
   @Override
@@ -73,8 +86,14 @@ public class MarkTableAction extends Abs
     for (StringExpression each : featureMap.keySet()) {
       map.put(each.getStringValue(block), featureMap.get(each).getIntegerValue(block));
     }
+    
+    boolean ignoreCaseValue = ignoreCase != null ? ignoreCase.getBooleanValue(element.getParent()) : false;
+    int ignoreLengthValue = ignoreLength != null ? ignoreLength.getIntegerValue(element.getParent()) : 0;
+    String ignoreCharValue = ignoreChar != null ? ignoreChar.getStringValue(element.getParent()) : "";
+    int maxIgnoreCharValue = maxIgnoreChar != null ? maxIgnoreChar.getIntegerValue(element.getParent()) : 0;
+    
     TextMarkerWordList wordList = table.getWordList(index);
-    Collection<AnnotationFS> found = wordList.find(stream, true, 0, new char[] {}, 0);
+    Collection<AnnotationFS> found = wordList.find(stream, ignoreCaseValue, ignoreLengthValue, ignoreCharValue.toCharArray(), maxIgnoreCharValue);
     for (AnnotationFS annotationFS : found) {
       List<String> rowWhere = table.getRowWhere(index - 1, annotationFS.getCoveredText());
       FeatureStructure newFS = stream.getCas().createFS(type);

Modified: uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/parser/TextMarkerParser.g
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/parser/TextMarkerParser.g?rev=1342714&r1=1342713&r2=1342714&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/parser/TextMarkerParser.g (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-textmarker/src/main/java/org/apache/uima/textmarker/parser/TextMarkerParser.g Fri May 25 16:26:54 2012
@@ -1162,11 +1162,15 @@ actionMarkTable returns [AbstractTextMar
     structure = typeExpression COMMA 
     index = numberExpression COMMA
     table = wordTableExpression 
-    (COMMA    
-    fname = stringExpression ASSIGN_EQUAL obj1 = numberExpression {map.put(fname,obj1);} 
-    (COMMA fname = stringExpression ASSIGN_EQUAL obj1 = numberExpression {map.put(fname,obj1);})*
-    )? RPAREN
-    {action = ActionFactory.createMarkTableAction(structure, index, table, map,$blockDeclaration::env);}
+    (COMMA key=stringExpression ASSIGN_EQUAL value = numberExpression)=>(COMMA key = stringExpression ASSIGN_EQUAL value = numberExpression{map.put(key,value);} )+
+    (COMMA ignoreCase = booleanExpression)=>(COMMA ignoreCase = booleanExpression 
+    COMMA ignoreLength = numberExpression 
+    COMMA ignoreChar = stringExpression
+    COMMA maxIgnoreChar = numberExpression)?
+    RPAREN
+
+
+    {action = ActionFactory.createMarkTableAction(structure, index, table, map, ignoreCase, ignoreLength, ignoreChar, maxIgnoreChar,$blockDeclaration::env);}
     ;
  
 actionGather returns [AbstractTextMarkerAction action = null]