summaryrefslogtreecommitdiff
path: root/decoder
diff options
context:
space:
mode:
authorChris Dyer <redpony@gmail.com>2014-05-17 17:46:20 -0400
committerChris Dyer <redpony@gmail.com>2014-05-17 17:46:20 -0400
commitbb3f703d572e9f4a4b971bfa2483e0caf060587d (patch)
tree367e3e0b0611c2d65de4b120f7ac1bc53cb5cd18 /decoder
parent926ed91f7364150eac0867097d80457999a8132f (diff)
stub for t2t translator
Diffstat (limited to 'decoder')
-rw-r--r--decoder/decoder.cc8
-rw-r--r--decoder/translator.h3
-rw-r--r--decoder/tree2string_translator.cc12
3 files changed, 14 insertions, 9 deletions
diff --git a/decoder/decoder.cc b/decoder/decoder.cc
index 41f36822..6783cad0 100644
--- a/decoder/decoder.cc
+++ b/decoder/decoder.cc
@@ -490,8 +490,8 @@ DecoderImpl::DecoderImpl(po::variables_map& conf, int argc, char** argv, istream
}
formalism = LowercaseString(str("formalism",conf));
- if (formalism != "t2s" && formalism != "scfg" && formalism != "fst" && formalism != "lextrans" && formalism != "pb" && formalism != "csplit" && formalism != "tagger" && formalism != "lexalign" && formalism != "rescore") {
- cerr << "Error: --formalism takes only 'scfg', 'fst', 'pb', 't2s', 'csplit', 'lextrans', 'lexalign', 'rescore', or 'tagger'\n";
+ if (formalism != "t2s" && formalism != "t2t" && formalism != "scfg" && formalism != "fst" && formalism != "lextrans" && formalism != "pb" && formalism != "csplit" && formalism != "tagger" && formalism != "lexalign" && formalism != "rescore") {
+ cerr << "Error: --formalism takes only 'scfg', 'fst', 'pb', 't2s', 't2t', 'csplit', 'lextrans', 'lexalign', 'rescore', or 'tagger'\n";
cerr << dcmdline_options << endl;
exit(1);
}
@@ -627,7 +627,9 @@ DecoderImpl::DecoderImpl(po::variables_map& conf, int argc, char** argv, istream
if (formalism == "scfg")
translator.reset(new SCFGTranslator(conf));
else if (formalism == "t2s")
- translator.reset(new Tree2StringTranslator(conf));
+ translator.reset(new Tree2StringTranslator(conf, false));
+ else if (formalism == "t2t")
+ translator.reset(new Tree2StringTranslator(conf, true));
else if (formalism == "fst")
translator.reset(new FSTTranslator(conf));
else if (formalism == "pb")
diff --git a/decoder/translator.h b/decoder/translator.h
index 72b2f0b0..ba218a0b 100644
--- a/decoder/translator.h
+++ b/decoder/translator.h
@@ -101,7 +101,8 @@ class RescoreTranslator : public Translator {
class Tree2StringTranslatorImpl;
class Tree2StringTranslator : public Translator {
public:
- Tree2StringTranslator(const boost::program_options::variables_map& conf);
+ Tree2StringTranslator(const boost::program_options::variables_map& conf,
+ bool has_multiple_states);
virtual std::string GetDecoderType() const;
protected:
bool TranslateImpl(const std::string& src,
diff --git a/decoder/tree2string_translator.cc b/decoder/tree2string_translator.cc
index 5d7aa5e2..101ed21c 100644
--- a/decoder/tree2string_translator.cc
+++ b/decoder/tree2string_translator.cc
@@ -23,7 +23,7 @@ struct Tree2StringGrammarNode {
// this needs to be rewritten so it is fast and checks errors well
// use a lexer probably
-void ReadTree2StringGrammar(istream* in, Tree2StringGrammarNode* root) {
+void ReadTree2StringGrammar(istream* in, Tree2StringGrammarNode* root, bool has_multiple_states) {
string line;
while(getline(*in, line)) {
size_t pos = line.find("|||");
@@ -143,7 +143,8 @@ struct Tree2StringTranslatorImpl {
vector<boost::shared_ptr<Tree2StringGrammarNode>> root;
bool add_pass_through_rules;
unsigned remove_grammars;
- Tree2StringTranslatorImpl(const boost::program_options::variables_map& conf) :
+ Tree2StringTranslatorImpl(const boost::program_options::variables_map& conf,
+ bool has_multiple_states) :
add_pass_through_rules(conf.count("add_pass_through_rules")) {
if (conf.count("grammar")) {
const vector<string> gf = conf["grammar"].as<vector<string>>();
@@ -152,7 +153,7 @@ struct Tree2StringTranslatorImpl {
for (auto& f : gf) {
ReadFile rf(f);
root[gc].reset(new Tree2StringGrammarNode);
- ReadTree2StringGrammar(rf.stream(), &*root[gc++]);
+ ReadTree2StringGrammar(rf.stream(), &*root[gc++], has_multiple_states);
}
}
}
@@ -357,8 +358,9 @@ struct Tree2StringTranslatorImpl {
}
};
-Tree2StringTranslator::Tree2StringTranslator(const boost::program_options::variables_map& conf) :
- pimpl_(new Tree2StringTranslatorImpl(conf)) {}
+Tree2StringTranslator::Tree2StringTranslator(const boost::program_options::variables_map& conf,
+ bool has_multiple_states) :
+ pimpl_(new Tree2StringTranslatorImpl(conf, has_multiple_states)) {}
bool Tree2StringTranslator::TranslateImpl(const string& input,
SentenceMetadata* smeta,