Currently supports all cakes listed on Wikipedia's official List of Cakes yes, that exists and some cake emojis. Will also return true if the input contains ends with 'cake', 'caek', or 'pie'. More support for other kinds of cake coming soon?
Feel free to add your own cakes and severely overcomplicate this block!
Hold on there for just one moment. Pie is not cake, and you cannot convince me otherwise. Pie is created very differently, has a crust, is made inside a pie tin, which resembles a bowl more than a plate (which is what a cake is cooked on). Plus, cake usually has some kind of frosting on top of it (not always, there are cakes without frosting).
So I came out 0 for 2 according to your program. First I typed "German chocolate." Not a cake, you say. Then "Black forest." Also not a cake. So I looked at your database and code. The trouble with my first attempt is that your database has it as "German chocolate cake." Some of the entries have "cake" in their names, while others don't. So, I think that you should remove the "cake" from those database entries that include it, and you should remove "cake" from the text the user enters before making any comparisons. Worse, the entry for Black forest cake is "Black Forest cake, often known as 'Black Forest gâteau' or 'Schwarzwälder Kirschtorte'." This should clearly be split into three entries.
Wikipedia tables are awesomely complete, but not necessarily clean, in the data science sense.
And I wouldn’t call “cake” the likes of “tiramisu” and “zuppa inglese” - lovely deserts, yes; cake, I don’t think so. That may be a matter of taste, though.
BTW I think it would be an interesting (i.e. freaking difficult) challenge for advanced Snappers to co-create an AI-ish version of this block that can actually reason about whether something is a cake.
Lol, I guess I should’ve looked at it a little closer… I’ll work on it soon
Edit
I seem to have a problem... I was considering trying this:
However, this presents the problem of things like "Apple cake", where "Apple" by itself wouldn't be considered a cake, or "Caterpillar cake" where "Caterpillar" is definitely (hopefully not) a cake... I guess I'll just leave the "cake" on some of them and remove it from others? I'm not sure what to do... any ideas?
Alrighty, I've updated it! Gimme some feedback... and some caek... Demo if you don't wanna scroll all the way back up
Changelog:
'pie' is no longer considered cake (see @ego-lay_atman-bay's post for why)
Some of the data entries have been fixed and their synonyms have been split up into different items
New Sensing block (didn't really know where to put it lol) to report data about cakes
Changed logic a bit; the input is now considered a cake if it is contained in the cake database or if it ends with the word 'cake' or 'caek'.
However, this presents the issue of people inventing their own cakes, which may or may not be a problem, however one could say something like "child cake" and still have it be considered a cake. Is this behavior good? I don't know really...
Also, since I changed it to check only the ending word rather than the whole string, one might find a cake which has the word 'cake' in a different position other than the end, causing it to be invalid... although said cake should probably already be on Wikipedia anyway :)
Possible Issues to figure out:
I'm not really sure how to deal with the issue I detailed in an edit of my previous post:
And again (like I said earlier in this post), should people be able to make up their own cakes?
What about trailing whitespace or other typos? Fixed!... might add more cake typos tho
...Are we absolutely sure Snap! isn't cake??
Etc.
Feel free to contribute! :D
Edit: More Changes!
Added variations of cake names to the database that don't have that special symbol stuff going on (ex. "Smörgåstårta" can also be written "Smorgastarta" and still be considered cake)
Excess whitespace is now ignored (thanks to @ego-lay_atman-bay for the solution)
Improved logic; now additionally checks if the input joined with ' cake' is registered in the database, which fixes the issue of the word 'cake' being omitted at the end of the input reporting false (thanks to @bh for bringing that up)........ except um...
I think this would more obviously the right answer if the block's name were changed to IS _ A CAKE? Or even, if that doesn't satisfy you, IS _ A KIND OF CAKE?
But I think that, as you suggest with the example of "child cake," accepting anything that has "cake" at the end is overbroad. Aside from made-up examples, consider "yellow cake," which is a form of uranium useful in making nuclear weapons. So I still think the right thing is to remove "cake" from the database entries, and from the input string before searching the database. (An input of just "cake" can be accepted as a special case, if you like.)