daily automatic beautifier

This commit is contained in:
MosesAdmin 2015-06-25 00:00:42 +01:00
parent dce0f33270
commit 4ec69fbfdf
2 changed files with 9 additions and 9 deletions

View File

@ -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;

View File

@ -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;
}