diff options
Diffstat (limited to 'lingo.cpp')
-rw-r--r-- | lingo.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lingo.cpp b/lingo.cpp index 64c97ac..ea4697d 100644 --- a/lingo.cpp +++ b/lingo.cpp | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <map> | 18 | #include <map> |
19 | #include <array> | 19 | #include <array> |
20 | #include <Magick++.h> | 20 | #include <Magick++.h> |
21 | #include <cctype> | ||
21 | #include "imagenet.h" | 22 | #include "imagenet.h" |
22 | 23 | ||
23 | #define ENABLE_BOT | 24 | #define ENABLE_BOT |
@@ -73,6 +74,10 @@ enum FilterDirection { | |||
73 | kTowardQuestion | 74 | kTowardQuestion |
74 | }; | 75 | }; |
75 | 76 | ||
77 | bool isDigitWrapper(unsigned char ch) { | ||
78 | return std::isdigit(ch); | ||
79 | } | ||
80 | |||
76 | verbly::filter makeHintFilter(verbly::filter subfilter, Height height, Colour colour, FilterDirection filter_direction) | 81 | verbly::filter makeHintFilter(verbly::filter subfilter, Height height, Colour colour, FilterDirection filter_direction) |
77 | { | 82 | { |
78 | switch (colour) { | 83 | switch (colour) { |
@@ -495,6 +500,22 @@ private: | |||
495 | return true; | 500 | return true; |
496 | } | 501 | } |
497 | } | 502 | } |
503 | } else if (height == kTop && colour == kYellow) { | ||
504 | std::set<std::string> hint_stressless; | ||
505 | for (const verbly::pronunciation& pronunciation : clue.getPronunciations()) { | ||
506 | std::string stressed = hatkirby::implode(pronunciation.getPhonemes(), " "); | ||
507 | std::string stressless; | ||
508 | std::remove_copy_if(stressed.begin(), stressed.end(), std::back_inserter(stressless), &isDigitWrapper); | ||
509 | hint_stressless.insert(stressless); | ||
510 | } | ||
511 | for (const verbly::pronunciation& pronunciation : solution.getPronunciations()) { | ||
512 | std::string stressed = hatkirby::implode(pronunciation.getPhonemes(), " "); | ||
513 | std::string stressless; | ||
514 | std::remove_copy_if(stressed.begin(), stressed.end(), std::back_inserter(stressless), &isDigitWrapper); | ||
515 | if (hint_stressless.count(stressless)) { | ||
516 | return true; | ||
517 | } | ||
518 | } | ||
498 | } | 519 | } |
499 | return false; | 520 | return false; |
500 | } | 521 | } |