c++ - Write output to new files at every nth iteration -


a fragment of code :

for (int iter = 0; iter < flags.total_iterations_; ++iter) {   if (iter%20==0) {       std::ofstream mf(flags.model_file_.c_str());  accum_model.appendasstring(word_index_map, mf); }    else { std::cout << "model not created "; }   std::cout << "iteration " << iter << " ...\n"; 

so, trying generate outputs method accum_model @ every 20th iteration. but, problem have write output in new file everytime 20th iteration reached. now, output being overwritten.

i execute code of executible, as:

 ./lda --num_topics 15 --alpha 0.1 --beta 0.01 --training_data_file testdata/test_data.txt --model_file mf/lda_model.txt --burn_in_iterations 120 --total_iterations 150 

the mf/lda_model.txt output file given. not understanding how link file contains code , executible command need 5 different new files (for 100 iterations - data written new file every 20th iteration).

i new coding , far, coding in python. tried till loop, confused how create new files , corresponding outputs. please help! in advance.

use std::stringstream, , build new file name open each time.

std::string uniquepathfilenamepostfix (int i) {    std::stringstream ss;    ss << '-' << ;        return (ss.str()); } 

the idea use stringstream create (or append or prepend) unique modifier based on i. (or else convenient - have used time stamps).


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

node.js - How to abort query on demand using Neo4j drivers -