summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Dyer <redpony@gmail.com>2014-04-01 00:53:00 -0400
committerChris Dyer <redpony@gmail.com>2014-04-01 00:53:00 -0400
commit17c8e9a7ef19fbd3158efc6fd40313ce7ca5273f (patch)
tree6de25609eb77d946ba11abf09bc9451dc0c28281
parent403c81d11ee572cc9c2d7fd7ebe8ab08691693a5 (diff)
tree2string test, fix for edge case
-rw-r--r--decoder/tree2string_translator.cc6
-rw-r--r--tests/system_tests/t2s/cdec.ini2
-rw-r--r--tests/system_tests/t2s/gold.statistics3
-rw-r--r--tests/system_tests/t2s/gold.stdout1
-rw-r--r--tests/system_tests/t2s/grammar.t2s8
-rw-r--r--tests/system_tests/t2s/input.txt1
-rw-r--r--tests/system_tests/t2s/weights6
7 files changed, 27 insertions, 0 deletions
diff --git a/decoder/tree2string_translator.cc b/decoder/tree2string_translator.cc
index 09eca147..7bc49132 100644
--- a/decoder/tree2string_translator.cc
+++ b/decoder/tree2string_translator.cc
@@ -167,6 +167,12 @@ struct Tree2StringTranslatorImpl {
//cerr << "Goal node: " << goal << endl;
hg.TopologicallySortNodesAndEdges(goal);
hg.Reweight(weights);
+
+ // there might be nodes that cannot be derived
+ // the following takes care of them
+ vector<bool> prune(hg.edges_.size(), false);
+ hg.PruneEdges(prune, true);
+
//hg.PrintGraphviz();
minus_lm_forest->swap(hg);
return true;
diff --git a/tests/system_tests/t2s/cdec.ini b/tests/system_tests/t2s/cdec.ini
new file mode 100644
index 00000000..ad83438f
--- /dev/null
+++ b/tests/system_tests/t2s/cdec.ini
@@ -0,0 +1,2 @@
+formalism=t2s
+grammar=grammar.t2s
diff --git a/tests/system_tests/t2s/gold.statistics b/tests/system_tests/t2s/gold.statistics
new file mode 100644
index 00000000..452cc93e
--- /dev/null
+++ b/tests/system_tests/t2s/gold.statistics
@@ -0,0 +1,3 @@
+-lm_nodes 6
+-lm_edges 8
+-lm_paths 4
diff --git a/tests/system_tests/t2s/gold.stdout b/tests/system_tests/t2s/gold.stdout
new file mode 100644
index 00000000..afb11818
--- /dev/null
+++ b/tests/system_tests/t2s/gold.stdout
@@ -0,0 +1 @@
+qiangshou bei jingfang jibi .
diff --git a/tests/system_tests/t2s/grammar.t2s b/tests/system_tests/t2s/grammar.t2s
new file mode 100644
index 00000000..2e6cf68c
--- /dev/null
+++ b/tests/system_tests/t2s/grammar.t2s
@@ -0,0 +1,8 @@
+(S [NP-C] [VP] (PUNC .)) ||| [1] [2] . ||| R1=1
+(NP-C (DT the) (NN gunman)) ||| qiangshou ||| R2=1
+(NP-C (DT the) [NN]) ||| [1] ||| R2a=1
+(NN gunman) ||| qiangshou ||| R2b=1
+(VP (VBD was) (VP-C [VBN] (PP (IN by) [NP-C]))) ||| bei [2] [1] ||| R3=1
+(NP-C (DT the) (NN police)) ||| jingfang ||| R4=1
+(VBN killed) ||| jibi ||| R5=1
+(VBN killed) ||| killed' ||| R6=1
diff --git a/tests/system_tests/t2s/input.txt b/tests/system_tests/t2s/input.txt
new file mode 100644
index 00000000..b8fe314e
--- /dev/null
+++ b/tests/system_tests/t2s/input.txt
@@ -0,0 +1 @@
+(S (NP-C (DT the) (NN gunman)) (VP (VBD was) (VP-C (VBN killed) (PP (IN by) (NP-C (DT the) (NN police))))) (PUNC .))
diff --git a/tests/system_tests/t2s/weights b/tests/system_tests/t2s/weights
new file mode 100644
index 00000000..4980db45
--- /dev/null
+++ b/tests/system_tests/t2s/weights
@@ -0,0 +1,6 @@
+R1 1
+R2a 1
+R2b 1
+R3 1
+R5 1
+R4 1