diff options
author | Phil Williams <philip.williams@mac.com> | 2015-02-02 19:34:17 +0300 |
---|---|---|
committer | Phil Williams <philip.williams@mac.com> | 2015-02-02 19:34:17 +0300 |
commit | c8ad84fa55f1f136d99fc4ff712e2aa421867c5d (patch) | |
tree | ed7e13ae176db234e8f9571ad9e468def49d3afb /moses/Syntax | |
parent | 984936f05fc3e241785c3aee35870a31a821eb2b (diff) |
New input type, ForestInput, for weighted forests.
* Uses Egret format (https://sites.google.com/site/zhangh1982/egret)
* Used by forest-to-string search algorithm (-search-algorithm 9)
Diffstat (limited to 'moses/Syntax')
-rw-r--r-- | moses/Syntax/F2S/Forest.h | 51 | ||||
-rw-r--r-- | moses/Syntax/PVertex.h | 5 |
2 files changed, 56 insertions, 0 deletions
diff --git a/moses/Syntax/F2S/Forest.h b/moses/Syntax/F2S/Forest.h new file mode 100644 index 000000000..6673b43be --- /dev/null +++ b/moses/Syntax/F2S/Forest.h @@ -0,0 +1,51 @@ +#pragma once + +#include "vector" + +#include "moses/Syntax/PVertex.h" + +namespace Moses +{ +namespace Syntax +{ +namespace F2S +{ + +class Forest +{ + public: + struct Vertex; + + struct Hyperedge { + Vertex *head; + std::vector<Vertex *> tail; + float weight; + }; + + struct Vertex { + Vertex(const PVertex &v) : pvertex(v) {} + ~Vertex(); // Deletes incoming hyperedges. + PVertex pvertex; + std::vector<Hyperedge *> incoming; + }; + + // Constructor. + Forest() {} + + // Destructor (deletes vertices). + ~Forest(); + + // Delete all vertices. + void Clear(); + + std::vector<Vertex *> vertices; + + private: + // Copying is not allowed. + Forest(const Forest &); + Forest &operator=(const Forest &); +}; + +} // namespace F2S +} // namespace Syntax +} // namespace Moses diff --git a/moses/Syntax/PVertex.h b/moses/Syntax/PVertex.h index 3a7a960c7..8832128b4 100644 --- a/moses/Syntax/PVertex.h +++ b/moses/Syntax/PVertex.h @@ -16,5 +16,10 @@ public: Word symbol; }; +inline bool operator==(const PVertex &v, const PVertex &w) +{ + return v.span == w.span && v.symbol == w.symbol; +} + } // Syntax } // Moses |