diff options
author | Feffernoose <fefferburbia@gmail.com> | 2013-10-05 21:14:14 -0400 |
---|---|---|
committer | Feffernoose <fefferburbia@gmail.com> | 2013-10-05 21:14:14 -0400 |
commit | 9f095cd071efa059449e4694f4fc3da22ca9e456 (patch) | |
tree | 405f1b052fb307213a97308adee7b268c778004f | |
parent | eb076ca2c6c8932fd251419563cf0078c5ee0914 (diff) | |
download | rawr-ebooks-9f095cd071efa059449e4694f4fc3da22ca9e456.tar.gz rawr-ebooks-9f095cd071efa059449e4694f4fc3da22ca9e456.tar.bz2 rawr-ebooks-9f095cd071efa059449e4694f4fc3da22ca9e456.zip |
Program no longer recalculates kgramstats repeatedly within each run
-rw-r--r-- | main.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/main.cpp b/main.cpp index 8310bf4..20f1a1f 100644 --- a/main.cpp +++ b/main.cpp | |||
@@ -17,19 +17,19 @@ int main(int argc, char** args) | |||
17 | { | 17 | { |
18 | srand(time(NULL)); | 18 | srand(time(NULL)); |
19 | 19 | ||
20 | YAML::Node config = YAML::LoadFile("config.yml"); | 20 | YAML::Node config = YAML::LoadFile("config.yml"); |
21 | 21 | ifstream infile(config["corpus"].as<std::string>().c_str()); | |
22 | for (;;) | 22 | string corpus; |
23 | string line; | ||
24 | while (getline(infile, line)) | ||
23 | { | 25 | { |
24 | ifstream infile(config["corpus"].as<std::string>().c_str()); | 26 | corpus += " " + line; |
25 | string corpus; | 27 | } |
26 | string line; | 28 | |
27 | while (getline(infile, line)) | 29 | kgramstats* stats = new kgramstats(corpus, 5); |
28 | { | ||
29 | corpus += " " + line; | ||
30 | } | ||
31 | 30 | ||
32 | kgramstats* stats = new kgramstats(corpus, 5); | 31 | for (;;) |
32 | { | ||
33 | vector<string> doc = stats->randomSentence(rand() % 25 + 5); | 33 | vector<string> doc = stats->randomSentence(rand() % 25 + 5); |
34 | string hi; | 34 | string hi; |
35 | for (vector<string>::iterator it = doc.begin(); it != doc.end(); ++it) | 35 | for (vector<string>::iterator it = doc.begin(); it != doc.end(); ++it) |