You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ctakes.apache.org by tm...@apache.org on 2012/10/25 23:15:08 UTC

svn commit: r1402332 - /incubator/ctakes/trunk/ctakes-type-system/src/main/java/org/apache/ctakes/typesystem/util/SimpleTree.java

Author: tmill
Date: Thu Oct 25 21:15:08 2012
New Revision: 1402332

URL: http://svn.apache.org/viewvc?rev=1402332&view=rev
Log:
Added isLeaf() utility method.  Changed to escape parens.

Modified:
    incubator/ctakes/trunk/ctakes-type-system/src/main/java/org/apache/ctakes/typesystem/util/SimpleTree.java

Modified: incubator/ctakes/trunk/ctakes-type-system/src/main/java/org/apache/ctakes/typesystem/util/SimpleTree.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-type-system/src/main/java/org/apache/ctakes/typesystem/util/SimpleTree.java?rev=1402332&r1=1402331&r2=1402332&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-type-system/src/main/java/org/apache/ctakes/typesystem/util/SimpleTree.java (original)
+++ incubator/ctakes/trunk/ctakes-type-system/src/main/java/org/apache/ctakes/typesystem/util/SimpleTree.java Thu Oct 25 21:15:08 2012
@@ -33,11 +33,17 @@ public class SimpleTree {
 	}
 	
 	public SimpleTree(String c, SimpleTree p){
-		cat = c;
+		cat = escapeCat(c);
 		children = new ArrayList<SimpleTree>();
 		parent = p;
 	}
 	
+	private String escapeCat(String c) {
+		c = c.replaceAll("\\(", "LPAREN");
+		c = c.replaceAll("\\)", "RPAREN");
+		return c;
+	}
+
 	public void addChild(SimpleTree t){
 		children.add(t);
 	}
@@ -117,6 +123,10 @@ public class SimpleTree {
 		return children.toArray(new String[]{});
 	}
 	
+ 	public boolean isLeaf() {
+ 		return children == null || children.size() == 0;
+ 	}
+ 	
 	public static void main(String[] args){
 		SimpleTree t = new SimpleTree("TOP");
 		t.addChild(new SimpleTree("S"));