ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r1513883 - /ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/tree/SimpleTree.java
Date Wed, 14 Aug 2013 13:45:55 GMT
Author: clin
Date: Wed Aug 14 13:45:54 2013
New Revision: 1513883

URL: http://svn.apache.org/r1513883
Log:
Enable the Simple Tree to print generalized terminal symbols.

Modified:
    ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/tree/SimpleTree.java

Modified: ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/tree/SimpleTree.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/tree/SimpleTree.java?rev=1513883&r1=1513882&r2=1513883&view=diff
==============================================================================
--- ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/tree/SimpleTree.java (original)
+++ ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/tree/SimpleTree.java Wed
Aug 14 13:45:54 2013
@@ -26,6 +26,7 @@ public class SimpleTree {
 	public String cat;
 	public ArrayList<SimpleTree> children;
 	public SimpleTree parent = null;
+	static boolean generalizeLeaf = false;
 	static Pattern ptPatt = Pattern.compile("\\(([^ (]+) +([^ )]+)\\)");
 	
 	public SimpleTree(String c){
@@ -38,6 +39,13 @@ public class SimpleTree {
 		parent = p;
 	}
 	
+	public SimpleTree(String c, SimpleTree p, boolean g){	
+		cat = escapeCat(c);
+		children = new ArrayList<SimpleTree>();
+		parent = p;
+		generalizeLeaf = g;
+	}
+	
 	private String escapeCat(String c) {
 		c = c.replaceAll("\\(", "LPAREN");
 		c = c.replaceAll("\\)", "RPAREN");
@@ -64,7 +72,11 @@ public class SimpleTree {
 		buff.append(cat);
 		buff.append(" ");
 		if(children.size() == 1 && children.get(0).children.size() == 0){
-			buff.append(children.get(0).cat);
+			if(generalizeLeaf){
+				buff.append("LEAF");
+			}else{
+				buff.append(children.get(0).cat);
+			}
 		}else{
 			for(int i = 0; i < children.size(); i++){
 				if(i != 0){
@@ -141,4 +153,9 @@ public class SimpleTree {
 	public boolean isLeaf() {
 		return children == null || children.size() == 0;
 	}
+
+	public void setGernalizeLeaf(boolean b) {
+		generalizeLeaf=b;
+		
+	}
 }



Mime
View raw message