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

Remote.h « LM « src « moses - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9a70d64c0d973f38059a79a22f7252de3c5e5e55 (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
#ifndef moses_LanguageModelRemote_h
#define moses_LanguageModelRemote_h

#include "LM/SingleFactor.h"
#include "TypeDef.h"
#include "Factor.h"
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>

namespace Moses
{

class LanguageModelRemote : public LanguageModelPointerState
{
private:
  struct Cache {
    std::map<const Factor*, Cache> tree;
    float prob;
    State boState;
    Cache() : prob(0) {}
  };

  int sock, port;
  struct hostent *hp;
  struct sockaddr_in server;
  mutable size_t m_curId;
  mutable Cache m_cache;
  bool start(const std::string& host, int port);
  static const Factor* BOS;
  static const Factor* EOS;
public:
  ~LanguageModelRemote();
  void ClearSentenceCache() {
    m_cache.tree.clear();
    m_curId = 1000;
  }
  virtual LMResult GetValue(const std::vector<const Word*> &contextFactor, State* finalState = 0) const;
  bool Load(const std::string &filePath
            , FactorType factorType
            , size_t nGramOrder);
};

}
#endif