|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once |
|
|
|
#include "TargetPhrase.h" |
|
#include "Vocab.h" |
|
#include <boost/shared_ptr.hpp> |
|
|
|
namespace Moses |
|
{ |
|
class TargetPhraseCollection; |
|
class PhraseDictionary; |
|
} |
|
|
|
namespace OnDiskPt |
|
{ |
|
|
|
|
|
|
|
class TargetPhraseCollection |
|
{ |
|
class TargetPhraseOrderByScore |
|
{ |
|
public: |
|
bool operator()(const TargetPhrase* a, const TargetPhrase *b) const { |
|
return a->GetScore(s_sortScoreInd) > b->GetScore(s_sortScoreInd); |
|
} |
|
}; |
|
|
|
protected: |
|
typedef std::vector<TargetPhrase*> CollType; |
|
CollType m_coll; |
|
uint64_t m_filePos; |
|
std::string m_debugStr; |
|
|
|
public: |
|
typedef boost::shared_ptr<TargetPhraseCollection const> shared_const_ptr; |
|
typedef boost::shared_ptr<TargetPhraseCollection> shared_ptr; |
|
|
|
static size_t s_sortScoreInd; |
|
|
|
TargetPhraseCollection(); |
|
TargetPhraseCollection(const TargetPhraseCollection ©); |
|
|
|
~TargetPhraseCollection(); |
|
void AddTargetPhrase(TargetPhrase *targetPhrase); |
|
void Sort(size_t tableLimit); |
|
|
|
void Save(OnDiskWrapper &onDiskWrapper); |
|
|
|
size_t GetSize() const { |
|
return m_coll.size(); |
|
} |
|
|
|
const TargetPhrase &GetTargetPhrase(size_t ind) const; |
|
|
|
uint64_t GetFilePos() const; |
|
|
|
void ReadFromFile(size_t tableLimit, uint64_t filePos, OnDiskWrapper &onDiskWrapper); |
|
|
|
const std::string GetDebugStr() const; |
|
void SetDebugStr(const std::string &str); |
|
|
|
}; |
|
|
|
} |
|
|
|
|