Welcome to mirror list, hosted at ThFree Co, Russian Federation.

LanguageModelInternal.h « src « moses - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1fd83c70d876f8c13e2e2de842b43de069cda1ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

#pragma once

#include "LanguageModelSingleFactor.h"
#include "NGramCollection.h"

/** Guaranteed cross-platform LM implementation designed to mimic LM used in regression tests
*/
class LanguageModelInternal : public LanguageModelSingleFactor
{
protected:
	std::vector<const NGramNode*> m_lmIdLookup;
	NGramCollection m_map;

	const NGramNode* GetLmID( const Factor *factor ) const
	{
		size_t factorId = factor->GetId();
		return ( factorId >= m_lmIdLookup.size()) ? NULL : m_lmIdLookup[factorId];        
  };

	float GetValue(const Factor *factor0, State* finalState) const;
	float GetValue(const Factor *factor0, const Factor *factor1, State* finalState) const;
	float GetValue(const Factor *factor0, const Factor *factor1, const Factor *factor2, State* finalState) const;

public:
	LanguageModelInternal(bool registerScore, ScoreIndexManager &scoreIndexManager);
	bool Load(const std::string &filePath
					, FactorType factorType
					, float weight
					, size_t nGramOrder);
	float GetValue(const std::vector<const Word*> &contextFactor
												, State* finalState = 0
												, unsigned int* len = 0) const;
};