summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Dyer <cdyer@allegro.clab.cs.cmu.edu>2014-05-17 19:04:31 -0400
committerChris Dyer <cdyer@allegro.clab.cs.cmu.edu>2014-05-17 19:04:31 -0400
commitddd99766d069c5ce5d41da304d7ba613657ee564 (patch)
treef749a707ed480f53b52430d3a3332af4f3cccd92
parentd1de1bb3fe271ce2f90a5885d70eddb859dd2354 (diff)
fix unique check
-rw-r--r--decoder/tree2string_translator.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/decoder/tree2string_translator.cc b/decoder/tree2string_translator.cc
index 8d624820..7b37887e 100644
--- a/decoder/tree2string_translator.cc
+++ b/decoder/tree2string_translator.cc
@@ -167,7 +167,7 @@ struct Tree2StringTranslatorImpl {
root.resize(root.size() + 1);
root.back().reset(new Tree2StringGrammarNode);
++remove_grammars;
- unordered_set<vector<unsigned>,boost::hash<vector<unsigned>>> unique_rule_check;
+ unordered_set<vector<int>,boost::hash<vector<int>>> unique_rule_check;
for (auto& prod : tree.nodes) {
int ntc = 0;
int lhs = -(prod.lhs & cdec::ALL_MASK);
@@ -179,9 +179,8 @@ struct Tree2StringTranslatorImpl {
}
// check for duplicate rule in tree
- vector<unsigned> key = prod.rhs;
+ vector<int> key;
key.push_back(prod.lhs);
- if (!unique_rule_check.insert(key).second) continue;
bool has_lex = false;
bool has_nt = false;
@@ -195,16 +194,19 @@ struct Tree2StringTranslatorImpl {
os << TD::Convert(sym);
rhse.push_back(sym);
rhsf.push_back(sym);
+ key.push_back(sym);
} else {
has_nt = true;
unsigned id = tree.nodes[sym & cdec::ALL_MASK].lhs & cdec::ALL_MASK;
os << '[' << TD::Convert(id) << ']';
rhsf.push_back(-id);
rhse.push_back(-ntc);
+ key.push_back(-id);
++ntc;
}
}
os << ')';
+ if (!unique_rule_check.insert(key).second) continue;
cdec::TreeFragment rule_src(os.str(), true);
Tree2StringGrammarNode* cur = root.back().get();
// do we need all transducer states here??? a list??? no pass through rules???