summaryrefslogtreecommitdiff
path: root/decoder/fdict.h
blob: d05f170643479e8a4de8d9ac369f5ed8c831a494 (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
#ifndef _FDICT_H_
#define _FDICT_H_

#include <string>
#include <vector>
#include "dict.h"

struct FD {
  // once the FD is frozen, new features not already in the
  // dictionary will return 0
  static void Freeze() {
    frozen_ = true;
  }
  static inline int NumFeats() {
    return dict_.max() + 1;
  }
  static inline WordID Convert(const std::string& s) {
    return dict_.Convert(s, frozen_);
  }
  static inline const std::string& Convert(const WordID& w) {
    return dict_.Convert(w);
  }
  static Dict dict_;
 private:
  static bool frozen_;
};

#endif