#include <PhraseDecoder.h>
Public Member Functions | |
PhraseDecoder (PhraseDictionaryCompact &phraseDictionary, const std::vector< FactorType > *input, const std::vector< FactorType > *output, size_t numScoreComponent) | |
~PhraseDecoder () | |
size_t | Load (std::FILE *in) |
TargetPhraseVectorPtr | CreateTargetPhraseCollection (const Phrase &sourcePhrase, bool topLevel=false, bool eval=true) |
TargetPhraseVectorPtr | DecodeCollection (TargetPhraseVectorPtr tpv, BitWrapper<> &encodedBitStream, const Phrase &sourcePhrase, bool topLevel, bool eval) |
void | PruneCache () |
Protected Types | |
enum | Coding { None, REnc, PREnc } |
typedef std::pair< unsigned char, unsigned char > | AlignPoint |
typedef std::pair< unsigned, unsigned > | SrcTrg |
Protected Member Functions | |
unsigned | GetSourceSymbolId (std::string &s) |
std::string | GetTargetSymbol (unsigned id) const |
size_t | GetREncType (unsigned encodedSymbol) |
size_t | GetPREncType (unsigned encodedSymbol) |
unsigned | GetTranslation (unsigned srcIdx, size_t rank) |
size_t | GetMaxSourcePhraseLength () |
unsigned | DecodeREncSymbol1 (unsigned encodedSymbol) |
unsigned | DecodeREncSymbol2Rank (unsigned encodedSymbol) |
unsigned | DecodeREncSymbol2Position (unsigned encodedSymbol) |
unsigned | DecodeREncSymbol3 (unsigned encodedSymbol) |
unsigned | DecodePREncSymbol1 (unsigned encodedSymbol) |
int | DecodePREncSymbol2Left (unsigned encodedSymbol) |
int | DecodePREncSymbol2Right (unsigned encodedSymbol) |
unsigned | DecodePREncSymbol2Rank (unsigned encodedSymbol) |
std::string | MakeSourceKey (std::string &) |
Protected Attributes | |
enum Moses::PhraseDecoder::Coding | m_coding |
size_t | m_numScoreComponent |
bool | m_containsAlignmentInfo |
size_t | m_maxRank |
size_t | m_maxPhraseLength |
boost::unordered_map < std::string, unsigned > | m_sourceSymbolsMap |
StringVector< unsigned char, unsigned, std::allocator > | m_sourceSymbols |
StringVector< unsigned char, unsigned, std::allocator > | m_targetSymbols |
std::vector< size_t > | m_lexicalTableIndex |
std::vector< SrcTrg > | m_lexicalTable |
CanonicalHuffman< unsigned > * | m_symbolTree |
bool | m_multipleScoreTrees |
std::vector< CanonicalHuffman < float > * > | m_scoreTrees |
CanonicalHuffman< AlignPoint > * | m_alignTree |
TargetPhraseCollectionCache | m_decodingCache |
PhraseDictionaryCompact & | m_phraseDictionary |
const std::vector< FactorType > * | m_input |
const std::vector< FactorType > * | m_output |
std::string | m_separator |
Friends | |
class | PhraseDictionaryCompact |
Definition at line 52 of file PhraseDecoder.h.
typedef std::pair<unsigned char, unsigned char> Moses::PhraseDecoder::AlignPoint [protected] |
Definition at line 58 of file PhraseDecoder.h.
typedef std::pair<unsigned, unsigned> Moses::PhraseDecoder::SrcTrg [protected] |
Definition at line 59 of file PhraseDecoder.h.
enum Moses::PhraseDecoder::Coding [protected] |
Moses::PhraseDecoder::PhraseDecoder | ( | PhraseDictionaryCompact & | phraseDictionary, | |
const std::vector< FactorType > * | input, | |||
const std::vector< FactorType > * | output, | |||
size_t | numScoreComponent | |||
) |
Definition at line 32 of file PhraseDecoder.cpp.
Moses::PhraseDecoder::~PhraseDecoder | ( | ) |
Definition at line 48 of file PhraseDecoder.cpp.
References m_alignTree, m_scoreTrees, and m_symbolTree.
TargetPhraseVectorPtr Moses::PhraseDecoder::CreateTargetPhraseCollection | ( | const Phrase & | sourcePhrase, | |
bool | topLevel = false , |
|||
bool | eval = true | |||
) |
Definition at line 193 of file PhraseDecoder.cpp.
References DecodeCollection(), Moses::BlockHashIndex::GetSize(), Moses::Phrase::GetStringRep(), m_coding, m_decodingCache, Moses::PhraseDictionaryCompact::m_hash, Moses::PhraseDictionaryCompact::m_inMemory, m_input, m_phraseDictionary, Moses::PhraseDictionaryCompact::m_targetPhrasesMapped, Moses::PhraseDictionaryCompact::m_targetPhrasesMemory, MakeSourceKey(), NULL, PREnc, Moses::TargetPhraseCollectionCache::Retrieve(), and Moses::BitWrapper< Container >::SeekFromEnd().
Referenced by DecodeCollection(), Moses::PhraseDictionaryCompact::GetTargetPhraseCollectionNonCacheLEGACY(), and Moses::PhraseDictionaryCompact::GetTargetPhraseCollectionRaw().
TargetPhraseVectorPtr Moses::PhraseDecoder::DecodeCollection | ( | TargetPhraseVectorPtr | tpv, | |
BitWrapper<> & | encodedBitStream, | |||
const Phrase & | sourcePhrase, | |||
bool | topLevel, | |||
bool | eval | |||
) |
Definition at line 248 of file PhraseDecoder.cpp.
References Moses::Phrase::AddWord(), Moses::Phrase::Append(), Moses::ScoreComponentCollection::Assign(), Moses::AlignmentInfo::begin(), Moses::TargetPhraseCollectionCache::Cache(), Moses::Word::CreateFromString(), CreateTargetPhraseCollection(), DecodePREncSymbol1(), DecodePREncSymbol2Left(), DecodePREncSymbol2Rank(), DecodePREncSymbol2Right(), DecodeREncSymbol1(), DecodeREncSymbol2Position(), DecodeREncSymbol2Rank(), DecodeREncSymbol3(), Moses::AlignmentInfo::end(), Moses::TargetPhrase::EvaluateInIsolation(), Moses::TargetPhrase::GetAlignTerm(), Moses::PhraseDictionary::GetFeaturesToApply(), GetPREncType(), GetREncType(), Moses::TargetPhrase::GetScoreBreakdown(), Moses::Phrase::GetSize(), GetSourceSymbolId(), Moses::Word::GetString(), Moses::Phrase::GetSubString(), GetTargetSymbol(), GetTranslation(), Moses::Phrase::GetWord(), m_alignTree, m_coding, m_containsAlignmentInfo, m_decodingCache, m_input, m_maxRank, m_multipleScoreTrees, m_numScoreComponent, m_output, m_phraseDictionary, m_scoreTrees, m_symbolTree, Moses::PhraseDictionaryCompact::m_useAlignmentInfo, NULL, Moses::Output, PREnc, Moses::CanonicalHuffman< Data >::Read(), REnc, Moses::TargetPhrase::SetAlignTerm(), state, and Moses::BitWrapper< Container >::TellFromEnd().
Referenced by CreateTargetPhraseCollection().
unsigned Moses::PhraseDecoder::DecodePREncSymbol1 | ( | unsigned | encodedSymbol | ) | [inline, protected] |
Definition at line 123 of file PhraseDecoder.cpp.
Referenced by DecodeCollection().
int Moses::PhraseDecoder::DecodePREncSymbol2Left | ( | unsigned | encodedSymbol | ) | [inline, protected] |
Definition at line 128 of file PhraseDecoder.cpp.
Referenced by DecodeCollection().
unsigned Moses::PhraseDecoder::DecodePREncSymbol2Rank | ( | unsigned | encodedSymbol | ) | [inline, protected] |
Definition at line 138 of file PhraseDecoder.cpp.
Referenced by DecodeCollection().
int Moses::PhraseDecoder::DecodePREncSymbol2Right | ( | unsigned | encodedSymbol | ) | [inline, protected] |
Definition at line 133 of file PhraseDecoder.cpp.
Referenced by DecodeCollection().
unsigned Moses::PhraseDecoder::DecodeREncSymbol1 | ( | unsigned | encodedSymbol | ) | [inline, protected] |
Definition at line 101 of file PhraseDecoder.cpp.
Referenced by DecodeCollection().
unsigned Moses::PhraseDecoder::DecodeREncSymbol2Position | ( | unsigned | encodedSymbol | ) | [inline, protected] |
Definition at line 111 of file PhraseDecoder.cpp.
Referenced by DecodeCollection().
unsigned Moses::PhraseDecoder::DecodeREncSymbol2Rank | ( | unsigned | encodedSymbol | ) | [inline, protected] |
Definition at line 106 of file PhraseDecoder.cpp.
Referenced by DecodeCollection().
unsigned Moses::PhraseDecoder::DecodeREncSymbol3 | ( | unsigned | encodedSymbol | ) | [inline, protected] |
Definition at line 118 of file PhraseDecoder.cpp.
Referenced by DecodeCollection().
size_t Moses::PhraseDecoder::GetMaxSourcePhraseLength | ( | ) | [protected] |
Definition at line 96 of file PhraseDecoder.cpp.
References m_maxPhraseLength.
Referenced by Moses::PhraseDictionaryCompact::GetTargetPhraseCollectionNonCacheLEGACY(), and Moses::PhraseDictionaryCompact::GetTargetPhraseCollectionRaw().
size_t Moses::PhraseDecoder::GetPREncType | ( | unsigned | encodedSymbol | ) | [inline, protected] |
Definition at line 85 of file PhraseDecoder.cpp.
Referenced by DecodeCollection().
size_t Moses::PhraseDecoder::GetREncType | ( | unsigned | encodedSymbol | ) | [inline, protected] |
Definition at line 80 of file PhraseDecoder.cpp.
Referenced by DecodeCollection().
unsigned Moses::PhraseDecoder::GetSourceSymbolId | ( | std::string & | s | ) | [inline, protected] |
Definition at line 61 of file PhraseDecoder.cpp.
References Moses::StringVector< ValueT, PosT, Allocator >::find(), m_sourceSymbols, and m_sourceSymbolsMap.
Referenced by DecodeCollection().
std::string Moses::PhraseDecoder::GetTargetSymbol | ( | unsigned | id | ) | const [inline, protected] |
Definition at line 73 of file PhraseDecoder.cpp.
References m_targetSymbols, and Moses::StringVector< ValueT, PosT, Allocator >::size().
Referenced by DecodeCollection().
unsigned Moses::PhraseDecoder::GetTranslation | ( | unsigned | srcIdx, | |
size_t | rank | |||
) | [inline, protected] |
Definition at line 90 of file PhraseDecoder.cpp.
References m_lexicalTable, and m_lexicalTableIndex.
Referenced by DecodeCollection().
size_t Moses::PhraseDecoder::Load | ( | std::FILE * | in | ) |
Definition at line 143 of file PhraseDecoder.cpp.
References end, ftell(), Moses::StringVector< ValueT, PosT, Allocator >::load(), m_alignTree, m_coding, m_containsAlignmentInfo, m_lexicalTable, m_lexicalTableIndex, m_maxPhraseLength, m_maxRank, m_multipleScoreTrees, m_numScoreComponent, m_scoreTrees, m_sourceSymbols, m_symbolTree, m_targetSymbols, read(), and REnc.
Referenced by Moses::PhraseDictionaryCompact::Load().
std::string Moses::PhraseDecoder::MakeSourceKey | ( | std::string & | source | ) | [protected] |
Definition at line 188 of file PhraseDecoder.cpp.
References m_separator.
Referenced by CreateTargetPhraseCollection().
void Moses::PhraseDecoder::PruneCache | ( | ) |
Definition at line 457 of file PhraseDecoder.cpp.
References m_decodingCache, and Moses::TargetPhraseCollectionCache::Prune().
Referenced by Moses::PhraseDictionaryCompact::CleanUpAfterSentenceProcessing().
friend class PhraseDictionaryCompact [friend] |
Definition at line 56 of file PhraseDecoder.h.
CanonicalHuffman<AlignPoint>* Moses::PhraseDecoder::m_alignTree [protected] |
Definition at line 80 of file PhraseDecoder.h.
Referenced by DecodeCollection(), Load(), and ~PhraseDecoder().
enum Moses::PhraseDecoder::Coding Moses::PhraseDecoder::m_coding [protected] |
Referenced by CreateTargetPhraseCollection(), DecodeCollection(), and Load().
bool Moses::PhraseDecoder::m_containsAlignmentInfo [protected] |
Definition at line 82 of file PhraseDecoder.h.
Referenced by CreateTargetPhraseCollection(), DecodeCollection(), and PruneCache().
const std::vector<FactorType>* Moses::PhraseDecoder::m_input [protected] |
Definition at line 88 of file PhraseDecoder.h.
Referenced by CreateTargetPhraseCollection(), and DecodeCollection().
std::vector<SrcTrg> Moses::PhraseDecoder::m_lexicalTable [protected] |
std::vector<size_t> Moses::PhraseDecoder::m_lexicalTableIndex [protected] |
size_t Moses::PhraseDecoder::m_maxPhraseLength [protected] |
Definition at line 66 of file PhraseDecoder.h.
Referenced by GetMaxSourcePhraseLength(), and Load().
size_t Moses::PhraseDecoder::m_maxRank [protected] |
bool Moses::PhraseDecoder::m_multipleScoreTrees [protected] |
size_t Moses::PhraseDecoder::m_numScoreComponent [protected] |
const std::vector<FactorType>* Moses::PhraseDecoder::m_output [protected] |
Definition at line 84 of file PhraseDecoder.h.
Referenced by CreateTargetPhraseCollection(), and DecodeCollection().
std::vector<CanonicalHuffman<float>*> Moses::PhraseDecoder::m_scoreTrees [protected] |
Definition at line 78 of file PhraseDecoder.h.
Referenced by DecodeCollection(), Load(), and ~PhraseDecoder().
std::string Moses::PhraseDecoder::m_separator [protected] |
StringVector<unsigned char, unsigned, std::allocator> Moses::PhraseDecoder::m_sourceSymbols [protected] |
boost::unordered_map<std::string, unsigned> Moses::PhraseDecoder::m_sourceSymbolsMap [protected] |
CanonicalHuffman<unsigned>* Moses::PhraseDecoder::m_symbolTree [protected] |
Definition at line 75 of file PhraseDecoder.h.
Referenced by DecodeCollection(), Load(), and ~PhraseDecoder().
StringVector<unsigned char, unsigned, std::allocator> Moses::PhraseDecoder::m_targetSymbols [protected] |