// Basic Interpolated LM class


#define SHIFT_BETA   1
#define SHIFT_ONE    2
#define SHIFT_ZERO   3
#define SHIFT_ONE_BETA   4
#define LINEAR_WB    5
#define LINEAR_GT    6
#define MIXTURE      7
#define MOD_SHIFT_BETA   8


class interplm:public ngramtable{
  
  int lms;

  double epsilon; //Bayes smoothing

  int unismooth; //0 Bayes, 1 Witten Bell

  int prune_singletons;

 public: 

  int backoff; //0 interpolation, 1 Back-off  

  interplm(char* ngtfile,int depth=0,TABLETYPE tt=FULL);

  int prunesingletons(int flag=-1){
    return (flag==-1?prune_singletons:prune_singletons=flag);
  }

  void gencorrcounts();

  void gensuccstat();

  virtual int dub(){return dict->dub();}

  virtual int dub(int value){ return (dict->dub(value)); }
  
  int setusmooth(int v=0){return unismooth=v;}

  double setepsilon(double v=1.0){return epsilon=v;}
  
  ngramtable *unitbl;
  
  void trainunigr();

  double unigr(ngram ng);

  double zerofreq(int lev);
  
  inline int lmsize(){return lms;}

  inline int obswrd(){return dict->size();}

  virtual int train(){return 0;};
  
  virtual void adapt(char* ngtfile, double w){};
  
  virtual double prob(ngram ng,int size){return 0.0;};

  virtual double boprob(ngram ng,int size){return 0.0;};
  
  void test_ngt(ngramtable& ngt,int sz=0,int backoff=0,int checkpr=0);

  void test_txt(char *filename,int sz=0,int backoff=0,int checkpr=0,char* outpr=NULL);
  
  void test(char* filename,int sz,int backoff=0,int checkpr=0,char* outpr=NULL);
  
  virtual int discount(ngram ng,int size,double& fstar,double& lambda,int cv=0){return 0;};

  virtual int savebin(char *filename,int lmsize=2){return 0;};
  
  virtual int netsize(){return 0;};
  
  void lmstat(int level){stat(level);};
  
  virtual ~interplm(){};
  
  
};








