summaryrefslogtreecommitdiff
path: root/decoder/hg_sampler.h
blob: 6ac39a20c864205e36f1f9277e2cbeeaeca409d7 (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
#ifndef _HG_SAMPLER_H_
#define _HG_SAMPLER_H_


#include <vector>
#include <string>
#include "sparse_vector.h"
#include "sampler.h"
#include "wordid.h"

class Hypergraph;

struct HypergraphSampler {

  struct Hypothesis {
    std::vector<WordID> words;
    SparseVector<double> fmap;
    prob_t model_score;   // log unnormalized probability
  };

  static void
  sample_hypotheses(const Hypergraph& hg,
                    unsigned n,   // how many samples to draw
                    MT19937* rng,
                    std::vector<Hypothesis>* hypos);

  static void
  sample_trees(const Hypergraph& hg,
               unsigned n,
               MT19937* rng,
               std::vector<std::string>* trees);
};

#endif