Skip to content

Commit

Permalink
combine output
Browse files Browse the repository at this point in the history
  • Loading branch information
mahmudhera committed Nov 7, 2024
1 parent c682943 commit d31c45f
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/cpp/compute_similarity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct Arguments {
int num_of_passes;
double containment_threshold;
bool combine;
string combined_output_filename;
};


Expand Down Expand Up @@ -86,6 +87,11 @@ void parse_arguments(int argc, char *argv[], Arguments &arguments) {
.default_value(false)
.implicit_value(true)
.store_into(arguments.combine);

// argument: combined output filename
parser.add_argument("-o", "--output")
.help("output filename (where the combined output will be written. Not used if -C is not present)")
.store_into(arguments.combined_output_filename);

parser.parse_args(argc, argv);

Expand Down Expand Up @@ -113,7 +119,8 @@ void show_arguments(Arguments& args) {
cout << "* number_of_threads: " << args.number_of_threads << endl;
cout << "* num_of_passes: " << args.num_of_passes << endl;
cout << "* containment_threshold: " << args.containment_threshold << endl;
cout << "* combine: " << args.combine << endl;
cout << "* combine: " << bool(args.combine) << endl;
cout << "* combined_output_filename: " << args.combined_output_filename << endl;
cout << "*" << endl;
cout << "**************************************" << endl;
}
Expand Down Expand Up @@ -175,5 +182,13 @@ int main(int argc, char** argv) {

cout << "similarity computation completed, results are here: " << args.output_directory << endl;

if (args.combine) {
cout << "Combining the output files..." << endl;
// cat all the files in the output directory
string command = "cat " + args.output_directory + "/*.txt > " + args.combined_output_filename;
system(command.c_str());
cout << "Combined output written to: " << args.combined_output_filename << endl;
}

return 0;
}

0 comments on commit d31c45f

Please sign in to comment.