From e0e5bd087ec34bf6097a58eb40be0bd3496e83a9 Mon Sep 17 00:00:00 2001 From: Paul Baltescu Date: Fri, 8 Mar 2013 16:00:47 +0000 Subject: Fixed stdout output order. --- extractor/run_extractor.cc | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'extractor/run_extractor.cc') diff --git a/extractor/run_extractor.cc b/extractor/run_extractor.cc index eb5600fe..e18336af 100644 --- a/extractor/run_extractor.cc +++ b/extractor/run_extractor.cc @@ -35,6 +35,11 @@ using namespace std; using namespace extractor; using namespace features; +fs::path GetGrammarFilePath(const fs::path& grammar_path, int file_number) { + string file_name = "grammar." + to_string(file_number); + return grammar_path / file_name; +} + int main(int argc, char** argv) { int num_threads_default = 1; #pragma omp parallel @@ -184,34 +189,32 @@ int main(int argc, char** argv) { } string sentence; - vector sentences; + vector sentences, suffixes; while (getline(cin, sentence)) { sentences.push_back(sentence); } #pragma omp parallel for schedule(dynamic) \ - num_threads(vm["threads"].as()) ordered + num_threads(vm["threads"].as()) for (size_t i = 0; i < sentences.size(); ++i) { - string delimiter = "|||"; - string suffix = ""; + string delimiter = "|||", suffix; int position = sentences[i].find(delimiter); if (position != sentences[i].npos) { suffix = sentences[i].substr(position); sentences[i] = sentences[i].substr(0, position); } + suffixes.push_back(suffix); Grammar grammar = extractor.GetGrammar(sentences[i]); - string file_name = "grammar." + to_string(i); - fs::path grammar_file = grammar_path / file_name; - ofstream output(grammar_file.c_str()); + ofstream output(GetGrammarFilePath(grammar_path, i).c_str()); output << grammar; + } - #pragma omp critical (stdout_write) - { - cout << " " - << sentences[i] << " " << suffix << endl; - } + for (size_t i = 0; i < sentences.size(); ++i) { + cout << " " << sentences[i] << " " << suffixes[i] << endl; } + Clock::time_point extraction_stop_time = Clock::now(); cerr << "Overall extraction step took " << GetDuration(extraction_start_time, extraction_stop_time) -- cgit v1.2.3