blob: f9fbf56c212aeec0c1ff3602de1618fbc070d378 (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
//
// Oliver Wilson <oliver.wilson@ed.ac.uk>
//
#ifndef moses_LanguageModelDMapLM_h
#define moses_LanguageModelDMapLM_h
#include <StructLanguageModelBackoff.h>
#include "Factor.h"
#include "FFState.h"
#include "LM/SingleFactor.h"
#include "Util.h"
namespace Moses {
class DMapLMState : public FFState {
public:
int Compare(const FFState &o) const {
const DMapLMState& cast_other = static_cast<const DMapLMState&>(o);
if (cast_other.m_last_succeeding_order < m_last_succeeding_order)
return -1;
else if (cast_other.m_last_succeeding_order > m_last_succeeding_order)
return 1;
else
return 0;
}
uint8_t m_last_succeeding_order;
};
class LanguageModelDMapLM : public LanguageModelSingleFactor
{
public:
LanguageModelDMapLM();
~LanguageModelDMapLM();
bool Load(const std::string&, FactorType, size_t);
LMResult GetValueGivenState(const std::vector<const Word*>&, FFState&) const;
LMResult GetValueForgotState(const std::vector<const Word*>&, FFState&) const;
float GetValue(const std::vector<const Word*>&, size_t, size_t*) const;
const FFState* GetNullContextState() const;
FFState* GetNewSentenceState() const;
const FFState* GetBeginSentenceState() const;
FFState* NewState(const FFState*) const;
void CleanUpAfterSentenceProcessing();
void InitializeBeforeSentenceProcessing();
protected:
StructLanguageModelBackoff* m_lm;
void CreateFactor(FactorCollection&);
};
} // namespace Moses
#endif // moses_LanguageModelDMapLM_h
|