diff options
-rw-r--r-- | lingo.cpp | 123 | ||||
m--------- | vendor/verbly | 0 |
2 files changed, 107 insertions, 16 deletions
diff --git a/lingo.cpp b/lingo.cpp index e13bb53..b549804 100644 --- a/lingo.cpp +++ b/lingo.cpp | |||
@@ -26,6 +26,7 @@ enum Colour { | |||
26 | kBlue, | 26 | kBlue, |
27 | kPurple, | 27 | kPurple, |
28 | kBrown, | 28 | kBrown, |
29 | kYellow, | ||
29 | kColourCount | 30 | kColourCount |
30 | }; | 31 | }; |
31 | 32 | ||
@@ -35,7 +36,8 @@ const std::string COLOUR_EMOJIS[kColourCount] = { | |||
35 | "🟥", | 36 | "🟥", |
36 | "🟦", | 37 | "🟦", |
37 | "🟪", | 38 | "🟪", |
38 | "🟫" | 39 | "🟫", |
40 | "🟨" | ||
39 | }; | 41 | }; |
40 | 42 | ||
41 | int main(int argc, char** argv) | 43 | int main(int argc, char** argv) |
@@ -60,14 +62,23 @@ int main(int argc, char** argv) | |||
60 | mastodonpp::Connection connection{instance};*/ | 62 | mastodonpp::Connection connection{instance};*/ |
61 | 63 | ||
62 | std::set<std::tuple<Height, Colour>> filters = { | 64 | std::set<std::tuple<Height, Colour>> filters = { |
63 | {kBottom, kWhite}, | ||
64 | {kBottom, kBlack}, | ||
65 | {kTop, kPurple}, | 65 | {kTop, kPurple}, |
66 | {kTop, kWhite}, | 66 | {kTop, kWhite}, |
67 | {kTop, kYellow}, | ||
68 | {kTop, kRed}, | ||
69 | {kTop, kBlue}, | ||
70 | {kMiddle, kYellow}, | ||
71 | {kMiddle, kRed}, | ||
72 | {kMiddle, kBlue}, | ||
73 | {kMiddle, kPurple}, | ||
74 | {kBottom, kWhite}, | ||
75 | {kBottom, kBlack}, | ||
67 | {kBottom, kRed}, | 76 | {kBottom, kRed}, |
68 | {kBottom, kBlue}, | 77 | {kBottom, kBlue}, |
69 | }; | 78 | }; |
70 | 79 | ||
80 | verbly::filter wordFilter = (verbly::form::proper == false); | ||
81 | |||
71 | verbly::filter cleanFilter = | 82 | verbly::filter cleanFilter = |
72 | !(verbly::word::usageDomains %= (verbly::notion::wnid == 106718862)) // ethnic slurs | 83 | !(verbly::word::usageDomains %= (verbly::notion::wnid == 106718862)) // ethnic slurs |
73 | && !(verbly::notion::wnid == 110630093); // "spastic" | 84 | && !(verbly::notion::wnid == 110630093); // "spastic" |
@@ -77,7 +88,7 @@ int main(int argc, char** argv) | |||
77 | bool puzzleEmpty = true; | 88 | bool puzzleEmpty = true; |
78 | std::array<std::optional<Colour>, kHeightCount> parts; | 89 | std::array<std::optional<Colour>, kHeightCount> parts; |
79 | for (int height = 0; height < static_cast<int>(kHeightCount); height++) { | 90 | for (int height = 0; height < static_cast<int>(kHeightCount); height++) { |
80 | if (std::bernoulli_distribution(0.4)(rng)) { | 91 | if (std::bernoulli_distribution(0.5)(rng)) { |
81 | int colour = std::uniform_int_distribution<int>(0, static_cast<int>(kColourCount)-1)(rng); | 92 | int colour = std::uniform_int_distribution<int>(0, static_cast<int>(kColourCount)-1)(rng); |
82 | if (filters.count({static_cast<Height>(height), static_cast<Colour>(colour)})) { | 93 | if (filters.count({static_cast<Height>(height), static_cast<Colour>(colour)})) { |
83 | parts[static_cast<Height>(height)] = static_cast<Colour>(colour); | 94 | parts[static_cast<Height>(height)] = static_cast<Colour>(colour); |
@@ -101,16 +112,16 @@ int main(int argc, char** argv) | |||
101 | case kWhite: { | 112 | case kWhite: { |
102 | switch (height) { | 113 | switch (height) { |
103 | case kBottom: { | 114 | case kBottom: { |
104 | forwardFilter &= (verbly::word::synonyms); | 115 | forwardFilter &= (verbly::word::synonyms %= wordFilter); |
105 | break; | 116 | break; |
106 | } | 117 | } |
107 | case kTop: { | 118 | case kTop: { |
108 | forwardFilter &= (verbly::form::pronunciations %= | 119 | forwardFilter &= (verbly::form::pronunciations %= |
109 | verbly::filter("homophones", false, | 120 | verbly::filter("homophones", false, |
110 | (verbly::pronunciation::forms %= verbly::filter( | 121 | (verbly::pronunciation::forms %= (wordFilter && verbly::filter( |
111 | verbly::form::id, | 122 | verbly::form::id, |
112 | verbly::filter::comparison::field_does_not_equal, | 123 | verbly::filter::comparison::field_does_not_equal, |
113 | verbly::form::id)))); | 124 | verbly::form::id))))); |
114 | break; | 125 | break; |
115 | } | 126 | } |
116 | default: break; // Not supposed yet. | 127 | default: break; // Not supposed yet. |
@@ -120,7 +131,7 @@ int main(int argc, char** argv) | |||
120 | case kBlack: { | 131 | case kBlack: { |
121 | switch (height) { | 132 | switch (height) { |
122 | case kBottom: { | 133 | case kBottom: { |
123 | forwardFilter &= (verbly::word::antonyms); | 134 | forwardFilter &= (verbly::word::antonyms %= wordFilter); |
124 | break; | 135 | break; |
125 | } | 136 | } |
126 | default: break; // Not supposed yet. | 137 | default: break; // Not supposed yet. |
@@ -130,7 +141,7 @@ int main(int argc, char** argv) | |||
130 | case kBrown: { | 141 | case kBrown: { |
131 | switch (height) { | 142 | switch (height) { |
132 | case kBottom: { | 143 | case kBottom: { |
133 | forwardFilter &= (verbly::notion::causes); | 144 | forwardFilter &= (verbly::notion::causes %= wordFilter); |
134 | break; | 145 | break; |
135 | } | 146 | } |
136 | default: break; // Not supposed yet. | 147 | default: break; // Not supposed yet. |
@@ -139,8 +150,16 @@ int main(int argc, char** argv) | |||
139 | } | 150 | } |
140 | case kRed: { | 151 | case kRed: { |
141 | switch (height) { | 152 | switch (height) { |
153 | case kTop: { | ||
154 | forwardFilter &= (verbly::pronunciation::holophones %= wordFilter); | ||
155 | break; | ||
156 | } | ||
157 | case kMiddle: { | ||
158 | forwardFilter &= (verbly::form::holographs %= wordFilter); | ||
159 | break; | ||
160 | } | ||
142 | case kBottom: { | 161 | case kBottom: { |
143 | forwardFilter &= (verbly::notion::partMeronyms); | 162 | forwardFilter &= (verbly::notion::partMeronyms %= wordFilter); |
144 | break; | 163 | break; |
145 | } | 164 | } |
146 | default: break; // Not supposed yet. | 165 | default: break; // Not supposed yet. |
@@ -149,8 +168,16 @@ int main(int argc, char** argv) | |||
149 | } | 168 | } |
150 | case kBlue: { | 169 | case kBlue: { |
151 | switch (height) { | 170 | switch (height) { |
171 | case kTop: { | ||
172 | forwardFilter &= (verbly::pronunciation::merophones %= wordFilter); | ||
173 | break; | ||
174 | } | ||
175 | case kMiddle: { | ||
176 | forwardFilter &= (verbly::form::merographs %= wordFilter); | ||
177 | break; | ||
178 | } | ||
152 | case kBottom: { | 179 | case kBottom: { |
153 | forwardFilter &= (verbly::notion::partHolonyms); | 180 | forwardFilter &= (verbly::notion::partHolonyms %= wordFilter); |
154 | break; | 181 | break; |
155 | } | 182 | } |
156 | default: break; // Not supposed yet. | 183 | default: break; // Not supposed yet. |
@@ -159,8 +186,32 @@ int main(int argc, char** argv) | |||
159 | } | 186 | } |
160 | case kPurple: { | 187 | case kPurple: { |
161 | switch (height) { | 188 | switch (height) { |
189 | case kMiddle: { | ||
190 | forwardFilter &= (verbly::form::merographs %= (verbly::form::length >= 4 && (verbly::form::holographs %= wordFilter))); | ||
191 | break; | ||
192 | } | ||
162 | case kTop: { | 193 | case kTop: { |
163 | forwardFilter &= (verbly::pronunciation::rhymes); | 194 | forwardFilter &= (verbly::pronunciation::rhymes %= wordFilter); |
195 | break; | ||
196 | } | ||
197 | default: break; // Not supposed yet. | ||
198 | } | ||
199 | break; | ||
200 | } | ||
201 | case kYellow: { | ||
202 | switch (height) { | ||
203 | case kTop: { | ||
204 | forwardFilter &= (verbly::pronunciation::anaphones %= (wordFilter && verbly::filter( | ||
205 | verbly::pronunciation::id, | ||
206 | verbly::filter::comparison::field_does_not_equal, | ||
207 | verbly::pronunciation::id))); | ||
208 | break; | ||
209 | } | ||
210 | case kMiddle: { | ||
211 | forwardFilter &= (verbly::form::anagrams %= (wordFilter && verbly::filter( | ||
212 | verbly::form::id, | ||
213 | verbly::filter::comparison::field_does_not_equal, | ||
214 | verbly::form::id))); | ||
164 | break; | 215 | break; |
165 | } | 216 | } |
166 | default: break; // Not supposed yet. | 217 | default: break; // Not supposed yet. |
@@ -171,7 +222,7 @@ int main(int argc, char** argv) | |||
171 | } | 222 | } |
172 | } | 223 | } |
173 | 224 | ||
174 | verbly::word solution = database.words(forwardFilter).first(); | 225 | verbly::form solution = database.forms(forwardFilter).first(); |
175 | 226 | ||
176 | for (int i=0; i<static_cast<int>(kHeightCount); i++) { | 227 | for (int i=0; i<static_cast<int>(kHeightCount); i++) { |
177 | Height height = static_cast<Height>(i); | 228 | Height height = static_cast<Height>(i); |
@@ -220,6 +271,14 @@ int main(int argc, char** argv) | |||
220 | } | 271 | } |
221 | case kBlue: { | 272 | case kBlue: { |
222 | switch (height) { | 273 | switch (height) { |
274 | case kTop: { | ||
275 | questionFilter = (verbly::pronunciation::holophones %= solution); | ||
276 | break; | ||
277 | } | ||
278 | case kMiddle: { | ||
279 | questionFilter = (verbly::form::holographs %= solution); | ||
280 | break; | ||
281 | } | ||
223 | case kBottom: { | 282 | case kBottom: { |
224 | /*questionFilter = ((verbly::notion::fullMemberHolonyms %= solution) | 283 | /*questionFilter = ((verbly::notion::fullMemberHolonyms %= solution) |
225 | || (verbly::notion::fullPartHolonyms %= solution) | 284 | || (verbly::notion::fullPartHolonyms %= solution) |
@@ -234,6 +293,14 @@ int main(int argc, char** argv) | |||
234 | } | 293 | } |
235 | case kRed: { | 294 | case kRed: { |
236 | switch (height) { | 295 | switch (height) { |
296 | case kTop: { | ||
297 | questionFilter = (verbly::pronunciation::merophones %= solution); | ||
298 | break; | ||
299 | } | ||
300 | case kMiddle: { | ||
301 | questionFilter = (verbly::form::merographs %= solution); | ||
302 | break; | ||
303 | } | ||
237 | case kBottom: { | 304 | case kBottom: { |
238 | /*questionFilter = ((verbly::notion::fullMemberMeronyms %= solution) | 305 | /*questionFilter = ((verbly::notion::fullMemberMeronyms %= solution) |
239 | || (verbly::notion::fullPartMeronyms %= solution) | 306 | || (verbly::notion::fullPartMeronyms %= solution) |
@@ -252,19 +319,43 @@ int main(int argc, char** argv) | |||
252 | questionFilter = (verbly::pronunciation::rhymes %= solution); | 319 | questionFilter = (verbly::pronunciation::rhymes %= solution); |
253 | break; | 320 | break; |
254 | } | 321 | } |
322 | case kMiddle: { | ||
323 | questionFilter = (verbly::form::merographs %= (verbly::form::length >= 4 && (verbly::form::holographs %= solution))); | ||
324 | break; | ||
325 | } | ||
326 | default: break; // Not supposed yet. | ||
327 | } | ||
328 | break; | ||
329 | } | ||
330 | case kYellow: { | ||
331 | switch (height) { | ||
332 | case kTop: { | ||
333 | questionFilter = (verbly::pronunciation::anaphones %= ((verbly::filter)solution && verbly::filter( | ||
334 | verbly::pronunciation::id, | ||
335 | verbly::filter::comparison::field_does_not_equal, | ||
336 | verbly::pronunciation::id))); | ||
337 | break; | ||
338 | } | ||
339 | case kMiddle: { | ||
340 | questionFilter = (verbly::form::anagrams %= ((verbly::filter)solution && verbly::filter( | ||
341 | verbly::form::id, | ||
342 | verbly::filter::comparison::field_does_not_equal, | ||
343 | verbly::form::id))); | ||
344 | break; | ||
345 | } | ||
255 | default: break; // Not supposed yet. | 346 | default: break; // Not supposed yet. |
256 | } | 347 | } |
257 | break; | 348 | break; |
258 | } | 349 | } |
259 | default: break; // Not supposed yet. | 350 | default: break; // Not supposed yet. |
260 | } | 351 | } |
261 | verbly::word questionPart = database.words(questionFilter && cleanFilter && (verbly::form::proper == false)).first(); | 352 | verbly::form questionPart = database.forms(questionFilter && cleanFilter).first(); |
262 | std::cout << COLOUR_EMOJIS[*colour] << " " << questionPart.getBaseForm().getText() << std::endl; | 353 | std::cout << COLOUR_EMOJIS[*colour] << " " << questionPart.getText() << std::endl; |
263 | } else { | 354 | } else { |
264 | std::cout << "▪️" << std::endl; | 355 | std::cout << "▪️" << std::endl; |
265 | } | 356 | } |
266 | } | 357 | } |
267 | std::cout << "(" << solution.getBaseForm().getText().size() << ")" << std::endl << std::endl << solution.getBaseForm().getText() << std::endl; | 358 | std::cout << "(" << solution.getText().size() << ")" << std::endl << std::endl << solution.getText() << std::endl; |
268 | 359 | ||
269 | 360 | ||
270 | // We can poll the timeline at most once every five minutes. | 361 | // We can poll the timeline at most once every five minutes. |
diff --git a/vendor/verbly b/vendor/verbly | |||
Subproject 84bae572d353b03ecb3498df83ba301a456b6c6 | Subproject 7ea3569e3894f19fbae6cfdb3406f2240570e3c | ||