blob: 403e18a08156cb75d00ec5e13b10ec7abd4fc2bf (
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
/**
* Epochal Phrase Extraction - extracted phrase pairs counter. Run this program
* the same way as phrase-extract/extract (without output files). Numbers of
* extracted phrase pairs for each length up to max-phrase-length will be
* reported.
*
* (C) Moses: http://www.statmt.org/moses/
* (C) Ceslav Przywara, UFAL MFF UK, 2011
*
* $Id$
*/
#include <string>
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <iomanip>
#include "phrase-extract.h"
#include "shared.h"
#define REQUIRED_PARAMS_NUM 4
void usage(const char* programName) {
std::cerr << "syntax: " << std::string(programName) << " tgt src align max-phrase-length [orientation [ --model [wbe|phrase|hier]-[msd|mslr|mono] ]]]\n";
exit(1);
}
/*******************************************************************************
* MAIN *
******************************************************************************/
int main(int argc, char** argv) {
if (argc <= REQUIRED_PARAMS_NUM) {
usage(argv[0]);
}
const char* fileNameE = argv[1];
const char* fileNameF = argv[2];
const char* fileNameA = argv[3];
maxPhraseLength = std::atoi(argv[4]);
//
read_optional_params(argc, argv, 5);
// Init phrase pairs counters (add +1 for dummy zero-length counter).
phrasePairsCounters.resize(maxPhraseLength + 1, 0);
std::cerr << "Starting phrase pairs counter ..." << std::endl;
// open input files
std::ifstream eFile(fileNameE);
std::ifstream fFile(fileNameF);
std::ifstream aFile(fileNameA);
//
readInput(eFile, fFile, aFile);
std::cerr << std::endl; // Leave the progress bar end on previous line.
// close input files
eFile.close();
fFile.close();
aFile.close();
std::cout
<< "############################" << std::endl
<< "# len # phrase pairs count #" << std::endl
<< "############################" << std::endl;
for ( size_t i = 1; i < phrasePairsCounters.size(); ++i ) {
std::cout << "# " << std::setw(3) << i << " # " << std::setw(18) << phrasePairsCounters[i] << " #" << std::endl;
}
std::cout
<< "############################" << std::endl;
}
|