forked from apertium/apertium-lex-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmultitrans.cc
63 lines (51 loc) · 1.45 KB
/
multitrans.cc
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
56
57
58
59
60
61
62
63
#include "multi_translator.h"
bool trim = false;
bool filter = false;
bool number_lines = false;
string path;
string mode;
void printError(char *name) {
wcout << "Usage: " << name << " ";
wcout << "<path to a binary bilingual transducer> <mode> [options]" << endl;
wcout << "Modes: " << endl;
wcout << " --biltrans | -b" << endl;
wcout << " --multitrans | -m" << endl;
wcout << " --trim-tagger-output | -p" << endl;
wcout << "Options: " << endl;
wcout << " --filter-lines | -f" << endl;
wcout << " --trim-lines | -t" << endl;
wcout << " --number-lines | -n" << endl;
}
void parseArguments(int argc, char **argv) {
if (argc < 3 || argc > 6) {
printError(argv[0]);
exit(1);
}
path = argv[1];
mode = argv[2];
if ( mode == "--biltrans") {
mode = "-b";
} else if (mode == "--multitrans") {
mode = "-m";
} else if (mode == "--tagger-output") {
mode = "-p";
}
if(mode != "-b" && mode != "-m" && mode != "-p") {
printError(argv[0]);
exit(1);
}
for(int i = 2; i < argc; i++) {
if(strcmp(argv[i], "-t") == 0 || strcmp(argv[i], "-trim-lines") == 0) {
trim = true;
} else if (strcmp(argv[i], "-f") == 0 || strcmp(argv[i], "-filter-lines") == 0) {
filter = true;
} else if (strcmp(argv[i], "-n") == 0 || strcmp(argv[i], "-number-lines") == 0) {
number_lines = true;
}
}
}
int main(int argc, char** argv) {
parseArguments(argc, argv);
MultiTranslator mt(path, mode, trim, filter, number_lines);
mt.processTaggerOutput();
}