|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once |
|
#ifndef EXTRACT_GHKM_ALIGNMENT_GRAPH_H_ |
|
#define EXTRACT_GHKM_ALIGNMENT_GRAPH_H_ |
|
|
|
#include <set> |
|
#include <string> |
|
#include <vector> |
|
|
|
#include "SyntaxTree.h" |
|
|
|
#include "Alignment.h" |
|
#include "Options.h" |
|
|
|
namespace MosesTraining |
|
{ |
|
namespace Syntax |
|
{ |
|
namespace GHKM |
|
{ |
|
|
|
class Node; |
|
class Subgraph; |
|
|
|
class AlignmentGraph |
|
{ |
|
public: |
|
AlignmentGraph(const SyntaxTree *, |
|
const std::vector<std::string> &, |
|
const Alignment &); |
|
|
|
~AlignmentGraph(); |
|
|
|
Node *GetRoot() { |
|
return m_root; |
|
} |
|
const std::vector<Node *> &GetTargetNodes() { |
|
return m_targetNodes; |
|
} |
|
|
|
void ExtractMinimalRules(const Options &); |
|
void ExtractComposedRules(const Options &); |
|
|
|
private: |
|
|
|
AlignmentGraph(const AlignmentGraph &); |
|
AlignmentGraph &operator=(const AlignmentGraph &); |
|
|
|
Node *CopyParseTree(const SyntaxTree *); |
|
void ComputeFrontierSet(Node *, const Options &, std::set<Node *> &) const; |
|
bool IsFrontierNode(const Node &, const Options &) const; |
|
void CalcComplementSpans(Node *); |
|
void GetTargetTreeLeaves(Node *, std::vector<Node *> &); |
|
void AttachUnalignedSourceWords(); |
|
Node *DetermineAttachmentPoint(int); |
|
Subgraph ComputeMinimalFrontierGraphFragment(Node *, |
|
const std::set<Node *> &); |
|
void ExtractComposedRules(Node *, const Options &); |
|
|
|
Node *m_root; |
|
std::vector<Node *> m_sourceNodes; |
|
std::vector<Node *> m_targetNodes; |
|
}; |
|
|
|
} |
|
} |
|
} |
|
|
|
#endif |
|
|