diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-01-29 12:43:00 -0500 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-01-29 12:43:00 -0500 |
commit | b316e309559d7176af6cf0bb7dcd6dbaa83c01cd (patch) | |
tree | f21bd883ef7c4255a91d096ea105feaad135ee52 /freevars.cpp | |
parent | fd1e9d59694c8a6ba201d2cdffec50f4f590841d (diff) | |
download | rawr-ebooks-b316e309559d7176af6cf0bb7dcd6dbaa83c01cd.tar.gz rawr-ebooks-b316e309559d7176af6cf0bb7dcd6dbaa83c01cd.tar.bz2 rawr-ebooks-b316e309559d7176af6cf0bb7dcd6dbaa83c01cd.zip |
Rewrote how tokens are handled
A 'word' is now an object that contains a distribution of forms that word can take. For now, most word just contain one form, the canonical one. The only special use is currently hashtags. Malapropisms have been disabled because of compatibility issues and because an upcoming feature is planned to replace it.
Diffstat (limited to 'freevars.cpp')
-rw-r--r-- | freevars.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/freevars.cpp b/freevars.cpp index 8c3eda4..54c5aab 100644 --- a/freevars.cpp +++ b/freevars.cpp | |||
@@ -34,8 +34,8 @@ std::string freevars::parse(std::string in) | |||
34 | for (std::map<std::string, std::vector<std::string>* >::iterator it = vars->begin(); it != vars->end(); it++) | 34 | for (std::map<std::string, std::vector<std::string>* >::iterator it = vars->begin(); it != vars->end(); it++) |
35 | { | 35 | { |
36 | std::string tofind = "$" + it->first + "$"; | 36 | std::string tofind = "$" + it->first + "$"; |
37 | size_t fpos = res.find(tofind); | 37 | size_t fpos; |
38 | if (fpos != std::string::npos) | 38 | while ((fpos = res.find(tofind)) != std::string::npos) |
39 | { | 39 | { |
40 | int r = rand() % it->second->size(); | 40 | int r = rand() % it->second->size(); |
41 | res.replace(fpos, tofind.length(), (*it->second)[r], 0, std::string::npos); | 41 | res.replace(fpos, tofind.length(), (*it->second)[r], 0, std::string::npos); |