X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2FForest.java;h=cdf8a8b634784b7c40ae2c5cce62e0e716d0764d;hp=1c8fbc5b6f8290bb0c6540a37fd2925900e7b89a;hb=0e17670bcfa7b0fe8eb3a2cac81f4b080a09fc98;hpb=f1dba2b015c3da04fc2fab45604da2e6c9ae0a1d
diff --git a/src/edu/berkeley/sbp/Forest.java b/src/edu/berkeley/sbp/Forest.java
index 1c8fbc5..cdf8a8b 100644
--- a/src/edu/berkeley/sbp/Forest.java
+++ b/src/edu/berkeley/sbp/Forest.java
@@ -7,8 +7,10 @@ import java.util.*;
import java.lang.reflect.*;
/**
+ *
* An efficient representation of a collection of trees (Tomita's
* shared packed parse forest).
+ *
*/
public abstract class Forest implements GraphViz.ToGraphViz {
@@ -19,18 +21,17 @@ public abstract class Forest implements GraphViz.ToGraphViz {
public void expand(HashSet> ht) { expand(ht, new HashSet>(), null); }
/** create a new forest */
- public static Forest create(Input.Region loc, T head, Forest[] children, boolean unwrap) {
- return new One(loc, head, children, unwrap);
+ public static Forest create(Input.Region loc, T head, Forest[] children, boolean lift) {
+ return new One(loc, head, children, lift);
}
// Package-Private //////////////////////////////////////////////////////////////////////////////
abstract void expand(HashSet> ht, HashSet> ignore, Tree bogus);
abstract void gather(HashSet> ignore);
+ abstract void edges(GraphViz.Node n);
boolean ambiguous() { return false; }
- public abstract void edges(GraphViz.Node n);
-
// One //////////////////////////////////////////////////////////////////////////////
@@ -42,21 +43,21 @@ public abstract class Forest implements GraphViz.ToGraphViz {
private final Forest[] children;
/** if true, the last child's children are considered children of this node */
- private final boolean unwrap;
+ private final boolean lift;
- private One(Input.Region loc, T head, Forest[] children, boolean unwrap) {
+ private One(Input.Region loc, T head, Forest[] children, boolean lift) {
this.location = loc;
this.head = head;
this.children = children==null ? emptyForestArray : new Forest[children.length];
if (children != null) System.arraycopy(children, 0, this.children, 0, children.length);
if (children != null) for(int i=0; i expand1() throws Ambiguous {
Tree[] ret = new Tree[children.length];
for(int i=0; i(location, head, ret, unwrap);
+ return new Tree(location, head, ret, lift);
}
void gather(HashSet> hf) {
@@ -69,7 +70,7 @@ public abstract class Forest implements GraphViz.ToGraphViz {
}
private void expand(final int i, Tree[] ta, HashSet> ht, HashSet> ignore, Tree bogus) {
if (i==children.length) {
- ht.add(new Tree(location, head, ta, unwrap));
+ ht.add(new Tree(location, head, ta, lift));
} else {
HashSet> ht2 = new HashSet>();
children[i].expand(ht2, ignore, bogus);
@@ -98,7 +99,7 @@ public abstract class Forest implements GraphViz.ToGraphViz {
if (edges) return;
edges = true;
for(int i=0; i