From 9f095cd071efa059449e4694f4fc3da22ca9e456 Mon Sep 17 00:00:00 2001 From: Feffernoose Date: Sat, 5 Oct 2013 21:14:14 -0400 Subject: Program no longer recalculates kgramstats repeatedly within each run --- main.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'main.cpp') 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) { srand(time(NULL)); - YAML::Node config = YAML::LoadFile("config.yml"); - - for (;;) + YAML::Node config = YAML::LoadFile("config.yml"); + ifstream infile(config["corpus"].as().c_str()); + string corpus; + string line; + while (getline(infile, line)) { - ifstream infile(config["corpus"].as().c_str()); - string corpus; - string line; - while (getline(infile, line)) - { - corpus += " " + line; - } + corpus += " " + line; + } + + kgramstats* stats = new kgramstats(corpus, 5); - kgramstats* stats = new kgramstats(corpus, 5); + for (;;) + { vector doc = stats->randomSentence(rand() % 25 + 5); string hi; for (vector::iterator it = doc.begin(); it != doc.end(); ++it) -- cgit 1.4.1