2015-10-24 01:19:31 +03:00
|
|
|
/*
|
|
|
|
* PhraseTable.h
|
|
|
|
*
|
|
|
|
* Created on: 23 Oct 2015
|
|
|
|
* Author: hieu
|
|
|
|
*/
|
|
|
|
#pragma once
|
2015-10-24 04:02:50 +03:00
|
|
|
#include <string>
|
2015-10-24 01:19:31 +03:00
|
|
|
#include <boost/unordered_map.hpp>
|
|
|
|
#include "TargetPhrases.h"
|
|
|
|
#include "Word.h"
|
2015-10-24 21:54:16 +03:00
|
|
|
#include "StatelessFeatureFunction.h"
|
2015-10-24 01:19:31 +03:00
|
|
|
#include "moses/Util.h"
|
|
|
|
|
2015-10-26 00:20:55 +03:00
|
|
|
class System;
|
2015-10-24 14:39:15 +03:00
|
|
|
class InputPaths;
|
2015-10-24 04:02:50 +03:00
|
|
|
|
2015-10-24 01:19:31 +03:00
|
|
|
class Node
|
|
|
|
{
|
2015-10-24 14:39:15 +03:00
|
|
|
public:
|
2015-10-24 21:54:16 +03:00
|
|
|
Node();
|
|
|
|
~Node();
|
2015-10-24 14:39:15 +03:00
|
|
|
void AddRule(Phrase &source, TargetPhrase *target);
|
2015-10-24 15:14:35 +03:00
|
|
|
const TargetPhrases *Find(const PhraseBase &source, size_t pos = 0) const;
|
2015-10-24 15:19:42 +03:00
|
|
|
|
2015-10-24 01:19:31 +03:00
|
|
|
protected:
|
|
|
|
typedef boost::unordered_map<Word, Node, Moses::UnorderedComparer<Word>, Moses::UnorderedComparer<Word> > Children;
|
|
|
|
Children m_children;
|
2015-10-24 21:54:16 +03:00
|
|
|
TargetPhrases *m_targetPhrases;
|
2015-10-24 14:39:15 +03:00
|
|
|
|
|
|
|
Node &AddRule(Phrase &source, TargetPhrase *target, size_t pos);
|
|
|
|
|
2015-10-24 01:19:31 +03:00
|
|
|
};
|
|
|
|
|
2015-10-24 15:31:43 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
2015-10-24 21:54:16 +03:00
|
|
|
class PhraseTable : public StatelessFeatureFunction
|
2015-10-24 01:19:31 +03:00
|
|
|
{
|
|
|
|
public:
|
2015-10-27 18:46:37 +03:00
|
|
|
PhraseTable(size_t startInd, const std::string &line);
|
2015-10-24 01:19:31 +03:00
|
|
|
virtual ~PhraseTable();
|
2015-10-26 00:20:55 +03:00
|
|
|
void Load(System &system);
|
2015-10-24 14:39:15 +03:00
|
|
|
void Lookups(InputPaths &inputPaths) const;
|
2015-10-24 01:19:31 +03:00
|
|
|
|
2015-10-24 15:31:43 +03:00
|
|
|
void SetPtInd(size_t ind)
|
|
|
|
{ m_ptInd = ind; }
|
|
|
|
size_t GetPtInd() const
|
|
|
|
{ return m_ptInd; }
|
|
|
|
|
2015-10-24 01:19:31 +03:00
|
|
|
protected:
|
|
|
|
Node m_root;
|
2015-10-24 04:02:50 +03:00
|
|
|
std::string m_path;
|
2015-10-24 15:19:42 +03:00
|
|
|
size_t m_ptInd;
|
2015-10-24 14:39:15 +03:00
|
|
|
|
2015-10-24 01:19:31 +03:00
|
|
|
};
|
|
|
|
|