From 4ebd159797a5db525fce7433e03858f8de96dce6 Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Thu, 9 Oct 2014 00:43:57 -0400 Subject: make tree terminals available to feature functions --- decoder/tree2string_translator.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'decoder/tree2string_translator.cc') diff --git a/decoder/tree2string_translator.cc b/decoder/tree2string_translator.cc index bd3b01d0..61a3aba5 100644 --- a/decoder/tree2string_translator.cc +++ b/decoder/tree2string_translator.cc @@ -287,6 +287,8 @@ struct Tree2StringTranslatorImpl { const vector& weights, Hypergraph* minus_lm_forest) { cdec::TreeFragment input_tree(input, false); + smeta->src_tree_ = input_tree; + smeta->input_type_ = cdec::kTREE; if (add_pass_through_rules) CreatePassThroughRules(input_tree); Hypergraph hg; hg.ReserveNodes(input_tree.nodes.size()); -- cgit v1.2.3 From 787792aedf4b6f9d90797814f8f719c39b82f0bb Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Sun, 12 Oct 2014 11:36:24 -0400 Subject: deal with alignments in tree to string grammars --- decoder/tree2string_translator.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'decoder/tree2string_translator.cc') diff --git a/decoder/tree2string_translator.cc b/decoder/tree2string_translator.cc index 61a3aba5..9cf18268 100644 --- a/decoder/tree2string_translator.cc +++ b/decoder/tree2string_translator.cc @@ -32,12 +32,12 @@ static void ReadTree2StringGrammar(istream* in, Tree2StringGrammarNode* root, bo ++lc; if (line.size() == 0 || line[0] == '#') continue; std::vector fields = TokenizeMultisep(line, " ||| "); - if (has_multiple_states && fields.size() != 4) { - cerr << "Expected 4 fields in rule file but line " << lc << " is:\n" << line << endl; + if (has_multiple_states && fields.size() < 5) { + cerr << "Expected at least 4 fields in rule file but line " << lc << " is:\n" << line << endl; abort(); } - if (!has_multiple_states && fields.size() != 3) { - cerr << "Expected 3 fields in rule file but line " << lc << " is:\n" << line << endl; + if (!has_multiple_states && fields.size() < 4) { + cerr << "Expected at least 3 fields in rule file but line " << lc << " is:\n" << line << endl; abort(); } @@ -73,6 +73,7 @@ static void ReadTree2StringGrammar(istream* in, Tree2StringGrammarNode* root, bo cerr << "Not implemented...\n"; abort(); // TODO read in states } else { os << " ||| " << fields[1] << " ||| " << fields[2]; + if (fields.size() > 3) os << " ||| " << fields[3]; rule.reset(new TRule(os.str())); } cur->rules.push_back(rule); -- cgit v1.2.3 From f83b9538087ca0cdc8289184c1e3e87c70b52a8e Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Sun, 12 Oct 2014 11:48:35 -0400 Subject: fix bug --- decoder/tree2string_translator.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'decoder/tree2string_translator.cc') diff --git a/decoder/tree2string_translator.cc b/decoder/tree2string_translator.cc index 9cf18268..08dae64c 100644 --- a/decoder/tree2string_translator.cc +++ b/decoder/tree2string_translator.cc @@ -32,11 +32,11 @@ static void ReadTree2StringGrammar(istream* in, Tree2StringGrammarNode* root, bo ++lc; if (line.size() == 0 || line[0] == '#') continue; std::vector fields = TokenizeMultisep(line, " ||| "); - if (has_multiple_states && fields.size() < 5) { + if (has_multiple_states && fields.size() < 4) { cerr << "Expected at least 4 fields in rule file but line " << lc << " is:\n" << line << endl; abort(); } - if (!has_multiple_states && fields.size() < 4) { + if (!has_multiple_states && fields.size() < 3) { cerr << "Expected at least 3 fields in rule file but line " << lc << " is:\n" << line << endl; abort(); } -- cgit v1.2.3 From cd7bc67f475fdfd07fba003ac4cca40e83944740 Mon Sep 17 00:00:00 2001 From: armatthews Date: Mon, 13 Oct 2014 14:59:16 -0400 Subject: Added alignment to pass through rules in t2s --- decoder/tree2string_translator.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'decoder/tree2string_translator.cc') diff --git a/decoder/tree2string_translator.cc b/decoder/tree2string_translator.cc index 08dae64c..cdd83ffc 100644 --- a/decoder/tree2string_translator.cc +++ b/decoder/tree2string_translator.cc @@ -267,6 +267,7 @@ struct Tree2StringTranslatorImpl { for (auto sym : rule_src) cur = &cur->next[sym]; TRulePtr rule(new TRule(rhse, rhsf, lhs)); + rule->a_.push_back(AlignmentPoint(0, 0)); rule->ComputeArity(); rule->scores_.set_value(ntfid, 1.0); rule->scores_.set_value(kFID, 1.0); -- cgit v1.2.3