Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarry Haddow <barry.haddow@gmail.com>2014-08-08 00:20:10 +0400
committerBarry Haddow <barry.haddow@gmail.com>2014-08-08 00:20:10 +0400
commitb5a1f02606f83209e0a1fe771f329cb9eedcef57 (patch)
tree4e71efa21deb703d149d8be2edf844be01b70f2f /moses/HypergraphOutput.h
parentfbe73dd06f89e0b17d9f3ec9e82d5c8f2add7fbd (diff)
Implement hypergraph output for chart moses
Diffstat (limited to 'moses/HypergraphOutput.h')
-rw-r--r--moses/HypergraphOutput.h45
1 files changed, 44 insertions, 1 deletions
diff --git a/moses/HypergraphOutput.h b/moses/HypergraphOutput.h
index 49f276d73..4ec8e2665 100644
--- a/moses/HypergraphOutput.h
+++ b/moses/HypergraphOutput.h
@@ -23,13 +23,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef moses_Hypergraph_Output_h
#define moses_Hypergraph_Output_h
+#include <ostream>
+
/**
* Manage the output of hypergraphs.
**/
namespace Moses {
-class Manager;
+class ChartHypothesisCollection;
template<class M>
class HypergraphOutput {
@@ -48,5 +50,46 @@ private:
bool m_appendSuffix;
};
+
+/**
+ * ABC for different types of search graph output for chart Moses.
+**/
+class ChartSearchGraphWriter {
+public:
+ virtual void WriteHeader(size_t winners, size_t losers) const = 0;
+ virtual void WriteHypos(const ChartHypothesisCollection& hypos,
+ const std::map<unsigned, bool> &reachable) const = 0;
+
+};
+
+/** "Moses" format (osg style) */
+class ChartSearchGraphWriterMoses : public virtual ChartSearchGraphWriter {
+public:
+ ChartSearchGraphWriterMoses(std::ostream* out, size_t lineNumber) :
+ m_out(out), m_lineNumber(lineNumber) {}
+ virtual void WriteHeader(size_t, size_t) const {/* do nothing */}
+ virtual void WriteHypos(const ChartHypothesisCollection& hypos,
+ const std::map<unsigned, bool> &reachable) const;
+
+private:
+ std::ostream* m_out;
+ size_t m_lineNumber;
+};
+
+/** Modified version of Kenneth's lazy hypergraph format */
+class ChartSearchGraphWriterHypergraph : public virtual ChartSearchGraphWriter {
+public:
+ ChartSearchGraphWriterHypergraph(std::ostream* out) :
+ m_out(out), m_nodeId(0) {}
+ virtual void WriteHeader(size_t winners, size_t losers) const;
+ virtual void WriteHypos(const ChartHypothesisCollection& hypos,
+ const std::map<unsigned, bool> &reachable) const;
+
+private:
+ std::ostream* m_out;
+ mutable size_t m_nodeId;
+ mutable std::map<size_t,size_t> m_hypoIdToNodeId;
+};
+
}
#endif