00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #pragma once
00021 #ifndef EXTRACT_GHKM_ALIGNMENT_GRAPH_H_
00022 #define EXTRACT_GHKM_ALIGNMENT_GRAPH_H_
00023
00024 #include <set>
00025 #include <string>
00026 #include <vector>
00027
00028 #include "SyntaxTree.h"
00029
00030 #include "Alignment.h"
00031 #include "Options.h"
00032
00033 namespace MosesTraining
00034 {
00035 namespace Syntax
00036 {
00037 namespace GHKM
00038 {
00039
00040 class Node;
00041 class Subgraph;
00042
00043 class AlignmentGraph
00044 {
00045 public:
00046 AlignmentGraph(const SyntaxTree *,
00047 const std::vector<std::string> &,
00048 const Alignment &);
00049
00050 ~AlignmentGraph();
00051
00052 Node *GetRoot() {
00053 return m_root;
00054 }
00055 const std::vector<Node *> &GetTargetNodes() {
00056 return m_targetNodes;
00057 }
00058
00059 void ExtractMinimalRules(const Options &);
00060 void ExtractComposedRules(const Options &);
00061
00062 private:
00063
00064 AlignmentGraph(const AlignmentGraph &);
00065 AlignmentGraph &operator=(const AlignmentGraph &);
00066
00067 Node *CopyParseTree(const SyntaxTree *);
00068 void ComputeFrontierSet(Node *, const Options &, std::set<Node *> &) const;
00069 bool IsFrontierNode(const Node &, const Options &) const;
00070 void CalcComplementSpans(Node *);
00071 void GetTargetTreeLeaves(Node *, std::vector<Node *> &);
00072 void AttachUnalignedSourceWords();
00073 Node *DetermineAttachmentPoint(int);
00074 Subgraph ComputeMinimalFrontierGraphFragment(Node *,
00075 const std::set<Node *> &);
00076 void ExtractComposedRules(Node *, const Options &);
00077
00078 Node *m_root;
00079 std::vector<Node *> m_sourceNodes;
00080 std::vector<Node *> m_targetNodes;
00081 };
00082
00083 }
00084 }
00085 }
00086
00087 #endif