mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
daily automatic beautifier
This commit is contained in:
parent
dce0f33270
commit
4ec69fbfdf
@ -12,7 +12,7 @@ int main(int argc, char **argv)
|
||||
{
|
||||
cerr << "Starting" << endl;
|
||||
int limit = atoi(argv[1]);
|
||||
|
||||
|
||||
vector<Rec> records;
|
||||
string prevInWord;
|
||||
string line;
|
||||
@ -20,12 +20,12 @@ int main(int argc, char **argv)
|
||||
vector<string> toks;
|
||||
Tokenize(toks, line);
|
||||
assert(toks.size() == 4);
|
||||
|
||||
|
||||
if (prevInWord != toks[0]) {
|
||||
Output(limit, records);
|
||||
records.clear();
|
||||
}
|
||||
|
||||
|
||||
// add new record
|
||||
float prob = atof(toks[2].c_str());
|
||||
records.push_back(Rec(prob, line));
|
||||
@ -37,13 +37,13 @@ int main(int argc, char **argv)
|
||||
Output(limit, records);
|
||||
records.clear();
|
||||
|
||||
cerr << "Finished" << endl;
|
||||
cerr << "Finished" << endl;
|
||||
}
|
||||
|
||||
void Output(int limit, vector<Rec> &records)
|
||||
{
|
||||
std::sort(records.rbegin(), records.rend());
|
||||
|
||||
|
||||
for (size_t i = 0; i < limit && i < records.size(); ++i) {
|
||||
const Rec &rec = records[i];
|
||||
cout << rec.line << endl;
|
||||
|
@ -7,12 +7,12 @@ class Rec
|
||||
public:
|
||||
float prob;
|
||||
std::string line;
|
||||
|
||||
|
||||
Rec(float aprob, const std::string &aline)
|
||||
:prob(aprob)
|
||||
,line(aline)
|
||||
:prob(aprob)
|
||||
,line(aline)
|
||||
{}
|
||||
|
||||
|
||||
inline bool operator< (const Rec &compare) const {
|
||||
return prob < compare.prob;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user