summaryrefslogtreecommitdiff
path: root/src/fast_weaver.cc
blob: bdf21f81d73a924ae4c5a7b229f0e9ab9d45aeca (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
#include "hypergraph.hh"
#include <ctime>

int
main(int argc, char** argv)
{
  clock_t begin_total = clock();

  // read hg
  clock_t begin_read = clock();
  Hg::Hypergraph hg;
  G::Vocabulary y;
  G::Grammar g;
  Hg::io::read(hg, g.rules, y, argv[1]);
  //Hg::io::manual(hg, g.rules);
  clock_t end_read = clock();
  double elapsed_secs_read = double(end_read - begin_read) / CLOCKS_PER_SEC;
  cerr << "read " << elapsed_secs_read << " s" << endl;

  // viterbi
  clock_t begin_viterbi = clock();
  Hg::Path p;
  Hg::viterbi_path(hg, p);
  vector<string> s;
  Hg::derive(p, p.back()->head, s);
  for (auto it: s)
    cout << it << " ";
  cout << endl;
  clock_t end_viterbi = clock();
  double elapsed_secs_viterbi = double(end_viterbi - begin_viterbi) / CLOCKS_PER_SEC;
  cerr << "viterbi " << elapsed_secs_viterbi << " s" << endl;

  clock_t end_total = clock();
  double elapsed_secs = double(end_total - begin_total) / CLOCKS_PER_SEC;
  cerr << "total " << elapsed_secs << " s" << endl;

  return 0;
}