summary refs log tree commit diff stats
path: root/lingo.cpp
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2023-02-17 09:34:28 -0500
committerStar Rauchenberger <fefferburbia@gmail.com>2023-02-17 09:34:28 -0500
commitf6c99467e83b7735bf4c6b13736726adc2d01d62 (patch)
tree349a19479f3fa24dfc7b9f7ebdc21e60aab290c0 /lingo.cpp
parentb85bd4ccaa663afa3e9805c7c33efae6b8b9f84c (diff)
downloadlingo-f6c99467e83b7735bf4c6b13736726adc2d01d62.tar.gz
lingo-f6c99467e83b7735bf4c6b13736726adc2d01d62.tar.bz2
lingo-f6c99467e83b7735bf4c6b13736726adc2d01d62.zip
Added top yellow triviality check for swapped stressed phonemes
Diffstat (limited to 'lingo.cpp')
-rw-r--r--lingo.cpp21
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
77bool isDigitWrapper(unsigned char ch) {
78 return std::isdigit(ch);
79}
80
76verbly::filter makeHintFilter(verbly::filter subfilter, Height height, Colour colour, FilterDirection filter_direction) 81verbly::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 }