diff options
Diffstat (limited to 'kgramstats.cpp')
| -rw-r--r-- | kgramstats.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
| diff --git a/kgramstats.cpp b/kgramstats.cpp index 1f3dd3c..648a267 100644 --- a/kgramstats.cpp +++ b/kgramstats.cpp | |||
| @@ -299,15 +299,18 @@ vector<string> kgramstats::randomSentence(int n) | |||
| 299 | return result; | 299 | return result; |
| 300 | } | 300 | } |
| 301 | 301 | ||
| 302 | bool removeIf(char c) | ||
| 303 | { | ||
| 304 | return !((c != '.') && (c != '"') && (c != '(') && (c != ')') && (c != ',')); | ||
| 305 | } | ||
| 306 | |||
| 302 | std::string canonize(std::string f) | 307 | std::string canonize(std::string f) |
| 303 | { | 308 | { |
| 304 | string canonical(f); | 309 | string canonical(f); |
| 305 | transform(canonical.begin(), canonical.end(), canonical.begin(), ::tolower); | 310 | transform(canonical.begin(), canonical.end(), canonical.begin(), ::tolower); |
| 306 | 311 | ||
| 307 | string result; | 312 | string result; |
| 308 | remove_copy_if(canonical.begin(), canonical.end(), std::back_inserter(result), [] (char c) { | 313 | remove_copy_if(canonical.begin(), canonical.end(), std::back_inserter(result), removeIf); |
| 309 | return !((c != '.') && (c != '"') && (c != '(') && (c != ')') && (c != ',')); | ||
| 310 | }); | ||
| 311 | 314 | ||
| 312 | return result; | 315 | return result; |
| 313 | } \ No newline at end of file | 316 | } \ No newline at end of file |
