Welcome to mirror list, hosted at ThFree Co, Russian Federation.

processLexicalTable.cpp « misc - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a81c6596502bd76d220d14cd80441c93b6ff5cb6 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <iostream>
#include <string>

#include "Timer.h"
#include "InputFileStream.h"
#include "LexicalReorderingTable.h"

using namespace Moses;

Timer timer;

void printHelp()
{
  std::cerr << "Usage:\n"
            "options: \n"
            "\t-in  string -- input table file name\n"
            "\t-out string -- prefix of binary table files\n"
            "If -in is not specified reads from stdin\n"
            "\n";
}

int main(int argc, char** argv)
{
  std::cerr << "processLexicalTable v0.1 by Konrad Rawlik\n";
  std::string inFilePath;
  std::string outFilePath("out");
  if(1 >= argc) {
    printHelp();
    return 1;
  }
  for(int i = 1; i < argc; ++i) {
    std::string arg(argv[i]);
    if("-in" == arg && i+1 < argc) {
      ++i;
      inFilePath = argv[i];
    } else if("-out" == arg && i+1 < argc) {
      ++i;
      outFilePath = argv[i];
    } else {
      //somethings wrong... print help
      printHelp();
      return 1;
    }
  }

  if(inFilePath.empty()) {
    std::cerr << "processing stdin to " << outFilePath << ".*\n";
    return LexicalReorderingTableTree::Create(std::cin, outFilePath);
  } else {
    std::cerr << "processing " << inFilePath<< " to " << outFilePath << ".*\n";
    InputFileStream file(inFilePath);
    bool success = LexicalReorderingTableTree::Create(file, outFilePath);
    return (success ? 0 : 1);
  }
}