From 294fe00911c6ee0dd9853df7612dcdbd63425c05 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 22 Nov 2015 16:25:12 -0500 Subject: I may have made things better. I may have made things worse. --- ebooks.cpp | 12 +++++++++--- gen.cpp | 10 ++++++++-- kgramstats.cpp | 10 +++++----- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/ebooks.cpp b/ebooks.cpp index a332351..8e46ee9 100644 --- a/ebooks.cpp +++ b/ebooks.cpp @@ -30,7 +30,7 @@ int main(int argc, char** args) } cout << "Preprocessing corpus..." << endl; - kgramstats* stats = new kgramstats(corpus, 5); + kgramstats* stats = new kgramstats(corpus, 3); cout << "Preprocessing freevars..." << endl; freevars* vars = new freevars(); @@ -46,6 +46,12 @@ int main(int argc, char** args) { hi += vars->parse(*it) + " "; } + + size_t lastperiod = hi.find_last_of("."); + if ((lastperiod != string::npos) && (rand() % 3 > 0)) + { + hi = hi.substr(0, lastperiod+1); + } hi = hi.substr(0,140); @@ -170,8 +176,8 @@ int main(int argc, char** args) printf( "\ntwitterClient:: twitCurl::statusUpdate error:\n%s\n", replyMsg.c_str() ); } - sleep(delay); + sleep(rand() % delay); } return 0; -} \ No newline at end of file +} diff --git a/gen.cpp b/gen.cpp index 1d381c8..31ba4dc 100644 --- a/gen.cpp +++ b/gen.cpp @@ -44,7 +44,7 @@ int main(int argc, char** args) } cout << "Preprocessing corpus..." << endl; - kgramstats* stats = new kgramstats(corpus, 5); + kgramstats* stats = new kgramstats(corpus, 3); cout << "Preprocessing freevars..." << endl; freevars* vars = new freevars(); @@ -61,10 +61,16 @@ int main(int argc, char** args) hi += vars->parse(*it) + " "; } + size_t lastperiod = hi.find_last_of("."); + if ((lastperiod != string::npos) && (rand() % 3 > 0)) + { + hi = hi.substr(0, lastperiod+1); + } + cout << hi << endl; getc(stdin); } return 0; -} \ No newline at end of file +} diff --git a/kgramstats.cpp b/kgramstats.cpp index 16bf598..b4e68eb 100644 --- a/kgramstats.cpp +++ b/kgramstats.cpp @@ -206,7 +206,7 @@ vector kgramstats::randomSentence(int n) { if (rand() % (maxK - cur.size() + 1) == 0) { - while (cur.size() > 0) + while (cur.size() > 1) { if ((rand() % (n)) < cuts) { @@ -246,7 +246,7 @@ vector kgramstats::randomSentence(int n) { nextToken[0] = toupper(nextToken[0]); } - + /* if (startquote < next->startquote) { nextToken = "\"" + nextToken; @@ -288,7 +288,7 @@ vector kgramstats::randomSentence(int n) nextToken += ","; } - +*/ if (cur.size() == maxK) { cur.pop_front(); @@ -336,5 +336,5 @@ std::string canonize(std::string f) string result; remove_copy_if(canonical.begin(), canonical.end(), std::back_inserter(result), removeIf); - return result; -} \ No newline at end of file + return canonical; +} -- cgit 1.4.1