From 252fb164c208ec8f3005f8a652eb3b48c0644e3d Mon Sep 17 00:00:00 2001 From: Paul Baltescu Date: Fri, 1 Feb 2013 16:11:10 +0000 Subject: Second working commit. --- extractor/grammar.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 extractor/grammar.cc (limited to 'extractor/grammar.cc') 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& rules, + const vector& 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; +} -- cgit v1.2.3