diff options
Diffstat (limited to 'gen.cpp')
-rw-r--r-- | gen.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/gen.cpp b/gen.cpp index 4e19f84..952e3b5 100644 --- a/gen.cpp +++ b/gen.cpp | |||
@@ -2,15 +2,15 @@ | |||
2 | #include <list> | 2 | #include <list> |
3 | #include <map> | 3 | #include <map> |
4 | #include "kgramstats.h" | 4 | #include "kgramstats.h" |
5 | #include <ctime> | ||
6 | #include <vector> | 5 | #include <vector> |
7 | #include <cstdlib> | ||
8 | #include <fstream> | 6 | #include <fstream> |
9 | #include <iostream> | 7 | #include <iostream> |
8 | #include <random> | ||
10 | 9 | ||
11 | int main(int argc, char** args) | 10 | int main(int argc, char** args) |
12 | { | 11 | { |
13 | srand(time(NULL)); | 12 | std::random_device randomDevice; |
13 | std::mt19937 rng(randomDevice()); | ||
14 | 14 | ||
15 | if (argc == 1) | 15 | if (argc == 1) |
16 | { | 16 | { |
@@ -73,7 +73,8 @@ int main(int argc, char** args) | |||
73 | size_t pos = form.find("$name$"); | 73 | size_t pos = form.find("$name$"); |
74 | if (pos != std::string::npos) | 74 | if (pos != std::string::npos) |
75 | { | 75 | { |
76 | form.replace(pos, 6, fv_names[rand() % fv_names.size()]); | 76 | int fvInd = std::uniform_int_distribution<int>(0, fv_names.size()-1)(rng); |
77 | form.replace(pos, 6, fv_names[fvInd]); | ||
77 | } | 78 | } |
78 | 79 | ||
79 | return form; | 80 | return form; |
@@ -82,7 +83,7 @@ int main(int argc, char** args) | |||
82 | std::cout << "Generating..." << std::endl; | 83 | std::cout << "Generating..." << std::endl; |
83 | for (;;) | 84 | for (;;) |
84 | { | 85 | { |
85 | std::string doc = kgramstats.randomSentence(140); | 86 | std::string doc = kgramstats.randomSentence(140, rng); |
86 | doc.resize(140); | 87 | doc.resize(140); |
87 | 88 | ||
88 | std::cout << doc << std::endl; | 89 | std::cout << doc << std::endl; |