summaryrefslogtreecommitdiff
path: root/decoder/apply_fsa_models.h
blob: 64ebab390408a405e236214e4c13f4fe4f33e19b (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
#ifndef _APPLY_FSA_MODELS_H_
#define _APPLY_FSA_MODELS_H_

#include <iostream>
#include "feature_vector.h"

struct FsaFeatureFunction;
struct Hypergraph;
struct SentenceMetadata;

struct ApplyFsaBy {
  enum {
    BU_CUBE,
    BU_FULL,
    EARLEY,
    N_ALGORITHMS
  };
  int pop_limit; // only applies to BU_FULL so far
  bool IsBottomUp() const {
    return algorithm==BU_FULL || algorithm==BU_CUBE;
  }
  int BottomUpAlgorithm() const;
  int algorithm;
  std::string name() const;
  friend inline std::ostream &operator << (std::ostream &o,ApplyFsaBy const& c) {
    return o << c.name();
  }
  explicit ApplyFsaBy(int alg, int poplimit=200);
  ApplyFsaBy(std::string const& name, int poplimit=200);
  ApplyFsaBy(const ApplyFsaBy &o) : algorithm(o.algorithm) {  }
  static std::string all_names(); // space separated
};


void ApplyFsaModels(const Hypergraph& in,
                    const SentenceMetadata& smeta,
                    const FsaFeatureFunction& fsa,
                    DenseWeightVector const& weights, // pre: in is weighted by these (except with fsa featval=0 before this)
                    ApplyFsaBy const& cfg,
                    Hypergraph* out);

#endif