about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ebooks.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/ebooks.cpp b/ebooks.cpp index 27065d9..6bbe25e 100644 --- a/ebooks.cpp +++ b/ebooks.cpp
@@ -19,34 +19,34 @@ int main(int argc, char** args)
19 YAML::Node config = YAML::LoadFile("config.yml"); 19 YAML::Node config = YAML::LoadFile("config.yml");
20 int delay = config["delay"].as<int>(); 20 int delay = config["delay"].as<int>();
21 21
22 ifstream infile(config["corpus"].as<std::string>().c_str()); 22 std::ifstream infile(config["corpus"].as<std::string>().c_str());
23 string corpus; 23 std::string corpus;
24 string line; 24 std::string line;
25 while (getline(infile, line)) 25 while (getline(infile, line))
26 { 26 {
27 corpus += " " + line; 27 corpus += " " + line;
28 } 28 }
29 29
30 cout << "Preprocessing corpus..." << endl; 30 std::cout << "Preprocessing corpus..." << std::endl;
31 kgramstats* stats = new kgramstats(corpus, 3); 31 kgramstats* stats = new kgramstats(corpus, 3);
32 32
33 cout << "Preprocessing freevars..." << endl; 33 std::cout << "Preprocessing freevars..." << std::endl;
34 freevars* vars = new freevars(); 34 freevars* vars = new freevars();
35 vars->addVar("name", "names.txt"); 35 vars->addVar("name", "names.txt");
36 vars->addVar("noun", "nouns.txt"); 36 vars->addVar("noun", "nouns.txt");
37 37
38 cout << "Generating..." << endl; 38 std::cout << "Generating..." << std::endl;
39 for (;;) 39 for (;;)
40 { 40 {
41 vector<string> doc = stats->randomSentence(rand() % 25 + 5); 41 std::vector<std::string> doc = stats->randomSentence(rand() % 25 + 5);
42 string hi; 42 std::string hi;
43 for (vector<string>::iterator it = doc.begin(); it != doc.end(); ++it) 43 for (std::vector<std::string>::iterator it = doc.begin(); it != doc.end(); ++it)
44 { 44 {
45 hi += vars->parse(*it) + " "; 45 hi += vars->parse(*it) + " ";
46 } 46 }
47 47
48 size_t lastperiod = hi.find_last_of("."); 48 size_t lastperiod = hi.find_last_of(".");
49 if ((lastperiod != string::npos) && (rand() % 3 > 0)) 49 if ((lastperiod != std::string::npos) && (rand() % 3 > 0))
50 { 50 {
51 hi = hi.substr(0, lastperiod+1); 51 hi = hi.substr(0, lastperiod+1);
52 } 52 }