/* itgdec.h
 *
 * Class declaration for decoder implementation.  Different
 * decoder implementations should inherit from this class.
 *
 * $Id: itgdec.h,v 1.11 2008/05/08 15:12:53 post Exp $
 */

#ifndef __ITGDEC_H__
#define __ITGDEC_H__

#include "itg.h"
#include "itgchart.h"
#include "feature.h"

using namespace std;

#define DECODEMAXV 255
//#define DEBUGLEXTRANS 1

class Decoder : public ITG {
 public:
  Decoder(ITGGrammar*, ITGCorp*);
  virtual ~Decoder() { }

  // finds the k best translations for a source language phrase
  int findkbest(WORDTYPE *, unsigned, list<WORDTYPE*> &);

  double push_lm_window(int *win, int word, int lm_size, 
                        int *uchoice);
  double compute_lm(int *ul, int *ur, int *vl, int *vr,
                    const Rule *rule,
                    int *uchoice, int *vchoice);

  int sentence() {  // puts next sentence in cn, returns 0 if past last sentence
    return corpus->retrieve(&cn, &T, MAXT);
  }

 protected:
  // maps from the candidate words found in the sentence to the first
  // N integers (for efficient representation)
  hash_map <WORDTYPE, WORDTYPE> candidates;

  bool USE_HOOKS;   // decode with the hook trick
  int MAXTRS;  // maximum number of translation candidates per source word
  int MAXINS;  // maximum number of insertion candidates
  int Vplus;
};

void dump_kbest(WORDTYPE* phrase, list <WORDTYPE*>& kbest);

#endif
