2013-10-29 02:11:37 +04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "SingleFactor.h"
|
|
|
|
|
2014-07-17 19:50:08 +04:00
|
|
|
#include <boost/thread/tss.hpp>
|
|
|
|
|
2015-01-14 14:07:42 +03:00
|
|
|
namespace nplm
|
|
|
|
{
|
|
|
|
class neuralLM;
|
2013-10-29 02:11:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace Moses
|
|
|
|
{
|
|
|
|
|
2013-10-29 03:21:02 +04:00
|
|
|
class NeuralLMWrapper : public LanguageModelSingleFactor
|
2013-10-29 02:11:37 +04:00
|
|
|
{
|
|
|
|
protected:
|
2014-07-17 19:50:08 +04:00
|
|
|
// big data (vocab, weights, cache) shared among threads
|
|
|
|
nplm::neuralLM *m_neuralLM_shared;
|
|
|
|
// thread-specific nplm for thread-safety
|
|
|
|
mutable boost::thread_specific_ptr<nplm::neuralLM> m_neuralLM;
|
2014-11-13 13:36:26 +03:00
|
|
|
int m_unk;
|
2013-10-29 02:11:37 +04:00
|
|
|
|
|
|
|
public:
|
2013-10-29 03:21:02 +04:00
|
|
|
NeuralLMWrapper(const std::string &line);
|
|
|
|
~NeuralLMWrapper();
|
2013-10-29 02:11:37 +04:00
|
|
|
|
|
|
|
virtual LMResult GetValue(const std::vector<const Word*> &contextFactor, State* finalState = 0) const;
|
|
|
|
|
2015-12-10 06:17:36 +03:00
|
|
|
virtual void Load(AllOptions::ptr const& opts);
|
2013-10-29 02:11:37 +04:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|