summaryrefslogtreecommitdiff
path: root/decoder/phrasetable_fst.h
blob: 477de1f7b2f6bea13114c19b16c9cce7380de939 (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 _PHRASETABLE_FST_H_
#define _PHRASETABLE_FST_H_

#include <vector>
#include <string>

#include "sparse_vector.h"
#include "trule.h"

class TargetPhraseSet {
 public:
  virtual ~TargetPhraseSet();
  virtual const std::vector<TRulePtr>& GetRules() const = 0;
};

class FSTNode {
 public:
  virtual ~FSTNode();
  virtual const TargetPhraseSet* GetTranslations() const = 0;
  virtual bool HasData() const = 0;
  virtual bool HasOutgoingNonEpsilonEdges() const = 0;
  virtual const FSTNode* Extend(const WordID& t) const = 0;

  // these should only be called on q_0:
  virtual void AddPassThroughTranslation(const WordID& w, const SparseVector<double>& feats) = 0;
  virtual void ClearPassThroughTranslations() = 0;
};

// attn caller: you own the memory
FSTNode* LoadTextPhrasetable(const std::vector<std::string>& filenames);
FSTNode* LoadTextPhrasetable(std::istream* in);
FSTNode* LoadBinaryPhrasetable(const std::string& fname_prefix);

#endif