diff options
-rw-r--r-- | ebooks.cpp | 12 | ||||
-rw-r--r-- | gen.cpp | 10 | ||||
-rw-r--r-- | 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) | |||
30 | } | 30 | } |
31 | 31 | ||
32 | cout << "Preprocessing corpus..." << endl; | 32 | cout << "Preprocessing corpus..." << endl; |
33 | kgramstats* stats = new kgramstats(corpus, 5); | 33 | kgramstats* stats = new kgramstats(corpus, 3); |
34 | 34 | ||
35 | cout << "Preprocessing freevars..." << endl; | 35 | cout << "Preprocessing freevars..." << endl; |
36 | freevars* vars = new freevars(); | 36 | freevars* vars = new freevars(); |
@@ -46,6 +46,12 @@ int main(int argc, char** args) | |||
46 | { | 46 | { |
47 | hi += vars->parse(*it) + " "; | 47 | hi += vars->parse(*it) + " "; |
48 | } | 48 | } |
49 | |||
50 | size_t lastperiod = hi.find_last_of("."); | ||
51 | if ((lastperiod != string::npos) && (rand() % 3 > 0)) | ||
52 | { | ||
53 | hi = hi.substr(0, lastperiod+1); | ||
54 | } | ||
49 | 55 | ||
50 | hi = hi.substr(0,140); | 56 | hi = hi.substr(0,140); |
51 | 57 | ||
@@ -170,8 +176,8 @@ int main(int argc, char** args) | |||
170 | printf( "\ntwitterClient:: twitCurl::statusUpdate error:\n%s\n", replyMsg.c_str() ); | 176 | printf( "\ntwitterClient:: twitCurl::statusUpdate error:\n%s\n", replyMsg.c_str() ); |
171 | } | 177 | } |
172 | 178 | ||
173 | sleep(delay); | 179 | sleep(rand() % delay); |
174 | } | 180 | } |
175 | 181 | ||
176 | return 0; | 182 | return 0; |
177 | } \ No newline at end of file | 183 | } |
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) | |||
44 | } | 44 | } |
45 | 45 | ||
46 | cout << "Preprocessing corpus..." << endl; | 46 | cout << "Preprocessing corpus..." << endl; |
47 | kgramstats* stats = new kgramstats(corpus, 5); | 47 | kgramstats* stats = new kgramstats(corpus, 3); |
48 | 48 | ||
49 | cout << "Preprocessing freevars..." << endl; | 49 | cout << "Preprocessing freevars..." << endl; |
50 | freevars* vars = new freevars(); | 50 | freevars* vars = new freevars(); |
@@ -61,10 +61,16 @@ int main(int argc, char** args) | |||
61 | hi += vars->parse(*it) + " "; | 61 | hi += vars->parse(*it) + " "; |
62 | } | 62 | } |
63 | 63 | ||
64 | size_t lastperiod = hi.find_last_of("."); | ||
65 | if ((lastperiod != string::npos) && (rand() % 3 > 0)) | ||
66 | { | ||
67 | hi = hi.substr(0, lastperiod+1); | ||
68 | } | ||
69 | |||
64 | cout << hi << endl; | 70 | cout << hi << endl; |
65 | 71 | ||
66 | getc(stdin); | 72 | getc(stdin); |
67 | } | 73 | } |
68 | 74 | ||
69 | return 0; | 75 | return 0; |
70 | } \ No newline at end of file | 76 | } |
diff --git a/kgramstats.cpp b/kgramstats.cpp index 16bf598..b4e68eb 100644 --- a/kgramstats.cpp +++ b/kgramstats.cpp | |||
@@ -206,7 +206,7 @@ vector<string> kgramstats::randomSentence(int n) | |||
206 | { | 206 | { |
207 | if (rand() % (maxK - cur.size() + 1) == 0) | 207 | if (rand() % (maxK - cur.size() + 1) == 0) |
208 | { | 208 | { |
209 | while (cur.size() > 0) | 209 | while (cur.size() > 1) |
210 | { | 210 | { |
211 | if ((rand() % (n)) < cuts) | 211 | if ((rand() % (n)) < cuts) |
212 | { | 212 | { |
@@ -246,7 +246,7 @@ vector<string> kgramstats::randomSentence(int n) | |||
246 | { | 246 | { |
247 | nextToken[0] = toupper(nextToken[0]); | 247 | nextToken[0] = toupper(nextToken[0]); |
248 | } | 248 | } |
249 | 249 | /* | |
250 | if (startquote < next->startquote) | 250 | if (startquote < next->startquote) |
251 | { | 251 | { |
252 | nextToken = "\"" + nextToken; | 252 | nextToken = "\"" + nextToken; |
@@ -288,7 +288,7 @@ vector<string> kgramstats::randomSentence(int n) | |||
288 | 288 | ||
289 | nextToken += ","; | 289 | nextToken += ","; |
290 | } | 290 | } |
291 | 291 | */ | |
292 | if (cur.size() == maxK) | 292 | if (cur.size() == maxK) |
293 | { | 293 | { |
294 | cur.pop_front(); | 294 | cur.pop_front(); |
@@ -336,5 +336,5 @@ std::string canonize(std::string f) | |||
336 | string result; | 336 | string result; |
337 | remove_copy_if(canonical.begin(), canonical.end(), std::back_inserter(result), removeIf); | 337 | remove_copy_if(canonical.begin(), canonical.end(), std::back_inserter(result), removeIf); |
338 | 338 | ||
339 | return result; | 339 | return canonical; |
340 | } \ No newline at end of file | 340 | } |