diff options
author | Paul Baltescu <pauldb89@gmail.com> | 2013-02-01 16:11:10 +0000 |
---|---|---|
committer | Paul Baltescu <pauldb89@gmail.com> | 2013-02-01 16:11:10 +0000 |
commit | 252fb164c208ec8f3005f8a652eb3b48c0644e3d (patch) | |
tree | 7199cb668e77ef89c7bcccb37d70554e3b52c2a5 /extractor/grammar.cc | |
parent | 4ab84a0be28fdb6c0c421fe5ba5e09cfa298f2d1 (diff) |
Second working commit.
Diffstat (limited to 'extractor/grammar.cc')
-rw-r--r-- | extractor/grammar.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/extractor/grammar.cc b/extractor/grammar.cc new file mode 100644 index 00000000..79a0541d --- /dev/null +++ b/extractor/grammar.cc @@ -0,0 +1,24 @@ +#include "grammar.h" + +#include "rule.h" + +Grammar::Grammar(const vector<Rule>& rules, + const vector<string>& feature_names) : + rules(rules), feature_names(feature_names) {} + +ostream& operator<<(ostream& os, const Grammar& grammar) { + for (Rule rule: grammar.rules) { + os << "[X] ||| " << rule.source_phrase << " ||| " + << rule.target_phrase << " |||"; + for (size_t i = 0; i < rule.scores.size(); ++i) { + os << " " << grammar.feature_names[i] << "=" << rule.scores[i]; + } + os << " |||"; + for (auto link: rule.alignment) { + os << " " << link.first << "-" << link.second; + } + os << endl; + } + + return os; +} |