summaryrefslogtreecommitdiff
path: root/decoder/earley_composer.h
blob: 31602f67516f2535bde42bd0520f6af2c5f952e3 (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
#ifndef EARLEY_COMPOSER_H_
#define EARLEY_COMPOSER_H_

#include <iostream>

class EarleyComposerImpl;
class FSTNode;
class Hypergraph;

class EarleyComposer {
 public:
  ~EarleyComposer();
  EarleyComposer(const FSTNode* phrasetable_root);
  bool Compose(const Hypergraph& src_forest, Hypergraph* trg_forest);

  // reads the grammar from a file. There must be a single top-level
  // S -> X rule.  Anything else is possible. Format is:
  // [S] ||| [SS,1]
  // [SS] ||| [NP,1] [VP,2] ||| Feature1=0.2 Feature2=-2.3
  // [SS] ||| [VP,1] [NP,2] ||| Feature1=0.8
  // [NP] ||| [DET,1] [N,2] ||| Feature3=2
  // ...
  bool Compose(std::istream* grammar_file, Hypergraph* trg_forest);

 private:
  EarleyComposerImpl* pimpl_;
};

#endif