diff --git a/lib/DDG/Goodie/PaleoIngredientCheck.pm b/lib/DDG/Goodie/PaleoIngredientCheck.pm index c597b5651..d301e8879 100644 --- a/lib/DDG/Goodie/PaleoIngredientCheck.pm +++ b/lib/DDG/Goodie/PaleoIngredientCheck.pm @@ -5,7 +5,7 @@ use DDG::Goodie; use List::MoreUtils 'any'; use YAML::XS qw(Load); -triggers startend => Load(scalar share('triggers.txt')->slurp); +triggers any => 'paleo', 'paleo friendly', 'paleo diet', 'paleo friendly?', 'paleo?'; zci answer_type => "paleo_ingredient_check"; zci is_cached => 1; @@ -21,58 +21,26 @@ attribution github => ["murz", "Mike Murray"]; attribution github => ["javathunderman", "Thomas Denizou"]; attribution twitter => ["javathunderman", "Thomas Denizou"]; -my @safe_keywords = Load(scalar share ('safe.txt')->slurp); -my @unsafe_keywords = Load(scalar share ('unsafe.txt')->slurp); - +my $safeornot = Load(scalar share('safeornot.yml')->slurp); handle remainder => sub { +my ($query,$ingredient,$safe); #Define vars - my $item = lc($_); + s/^paleo friendly (diet)?//g; # strip common words + $query = $_; - # Remove any preceding "is" or "are" text from the query. - $item =~ s/^(is|are)[\W]+//; - my $is_plural = substr($item, -1) eq "s"; - my($result); +return unless $ingredient; +$safe= $safeornot->{$ingredient} +return unless $safe; +if ($safe eq "0") {$safe = $ingredient." is safe";} +else if ($safe eq "1") {$safe= $ingredient."is not safe";} +return $ingredient . " is $safe", + structured_answer => { + input => [$ingredient], + operation => 'paleo', + result => $safe + }; - if (any {/$item/} @safe_keywords) { - # If we know the item is safe, append the appropriate positive result. - if ($is_plural) { - $result = "are"; - } else { - $result = "is"; - } - } elsif (any {/$item/} @unsafe_keywords) { - # If we know the item is unsafe, append the appropriate negative result. - if ($is_plural) { - $result = "are not"; - } else { - $result = "is not"; - } - } elsif (!$is_plural) { - # If nothing was found and the query was not plural, try it pluralized. - if (any {/$item."s"/} @safe_keywords) { - $result = "is"; - } elsif (any {/$item."s"/} @unsafe_keywords) { - $result = "is not"; - } - } elsif ($is_plural) { - # If nothing was found and the query was plural, try it depluralized. - my $depluralized = substr($item, 0, -1); - if (any {/$depluralized/} @safe_keywords) { - $result = "are"; - } elsif (any {/$depluralized/} @unsafe_keywords) { - $result = "are not"; - } - } - - return unless $result; - my $plaintext = ucfirst($item) . " $result allowed on the paleo diet."; - return $plaintext, - structured_answer => { - input => "Is $item paleo-diet friendly", # or just the original query - operation => "", - result => $plaintext, # this could possibly be shortened to a simple "Yes" or "No" -}; }; 1; \ No newline at end of file diff --git a/share/goodie/paleo_ingredient_check/safe.txt b/share/goodie/paleo_ingredient_check/safe.txt deleted file mode 100644 index 674c8486b..000000000 --- a/share/goodie/paleo_ingredient_check/safe.txt +++ /dev/null @@ -1,131 +0,0 @@ -poultry -turkey -chicken breast -pork tenderloin -pork chops -steak -veal -bacon -pork -beef -ground beef -grass-fed beef -grassfed beef -chicken thigh -chicken leg -chicken wings -lamb rack -shrimp -lobster -clams -salmon -venison steaks -buffalo -new york steak -bison -bison steaks -bison jerky -bison ribeye -bison sirloin -lamb chops -rabbit -goat -elk -emu -goose -kangaroo -bear -beef jerky -eggs -duck eggs -chicken eggs -goose eggs -wild boar -reindeer -turtle -ostrich -pheasant -quail -lean veal -chuck steak -rattlesnake -bass -salmon -halibut -mackerel -sardines -tuna -red snapper -shark -sunfish -swordfish -tilapia -trout -walleye -crab -crawfish -crayfish -shrimp -clams -lobster -scallops -oysters -asparagus -avocado -artichoke hearts -brussels sprouts -carrots -spinach -celery -broccoli -zucchini -cabbage -peppers -cauliflower -parsley -eggplant -green onions -butternut squash -acorn squash -yam -yucca -sweet potato -sweet potatoes -beets -coconut oil -olive oil -macadamia oil -avocado oil -grass-fed butter -almonds -cashews -hazelnuts -pecans -pine nuts -pumpkin seeds -sunflower seeds -macadamia nuts -walnuts -apple -avocado -blackberries -papaya -peaches -plums -mango -lychee -blueberries -grapes -lemon -strawberries -watermelon -pineapple guava -lime -raspberries -cantaloupe -tangerine -figs -oranges -bananas -potatoes -potato \ No newline at end of file diff --git a/share/goodie/paleo_ingredient_check/safe.yml b/share/goodie/paleo_ingredient_check/safe.yml new file mode 100644 index 000000000..932d0bd87 --- /dev/null +++ b/share/goodie/paleo_ingredient_check/safe.yml @@ -0,0 +1,339 @@ +poultry:0 +turkey:0 +chicken breast:0 +pork tenderloin:0 +pork chops:0 +steak:0 +veal:0 +bacon:0 +pork:0 +beef:0 +ground beef:0 +grass-fed beef:0 +grassfed beef:0 +chicken thigh:0 +chicken leg:0 +chicken wings:0 +lamb rack:0 +shrimp:0 +lobster:0 +clams:0 +salmon:0 +venison steaks:0 +buffalo:0 +new york steak:0 +bison:0 +bison steaks:0 +bison jerky:0 +bison ribeye:0 +bison sirloin:0 +lamb chops:0 +rabbit:0 +goat:0 +elk:0 +emu:0 +goose:0 +kangaroo:0 +bear:0 +beef jerky:0 +eggs:0 +duck eggs:0 +chicken eggs:0 +goose eggs:0 +wild boar:0 +reindeer:0 +turtle:0 +ostrich:0 +pheasant:0 +quail:0 +lean veal:0 +chuck steak:0 +rattlesnake:0 +bass:0 +salmon:0 +halibut:0 +mackerel:0 +sardines:0 +tuna:0 +red snapper:0 +shark:0 +sunfish:0 +swordfish:0 +tilapia:0 +trout:0 +walleye:0 +crab:0 +crawfish:0 +crayfish:0 +shrimp:0 +clams:0 +lobster:0 +scallops:0 +oysters:0 +asparagus:0 +avocado:0 +artichoke hearts:0 +brussels sprouts:0 +carrots:0 +spinach:0 +celery:0 +broccoli:0 +zucchini:0 +cabbage:0 +peppers:0 +cauliflower:0 +parsley:0 +eggplant:0 +green onions:0 +butternut squash:0 +acorn squash:0 +yam:0 +yucca:0 +sweet potato:0 +sweet potatoes:0 +beets:0 +coconut oil:0 +olive oil:0 +macadamia oil:0 +avocado oil:0 +grass-fed butter:0 +almonds:0 +cashews:0 +hazelnuts:0 +pecans:0 +pine nuts:0 +pumpkin seeds:0 +sunflower seeds:0 +macadamia nuts:0 +walnuts:0 +apple:0 +avocado:0 +blackberries:0 +papaya:0 +peaches:0 +plums:0 +mango:0 +lychee:0 +blueberries:0 +grapes:0 +lemon:0 +strawberries:0 +watermelon:0 +pineapple guava:0 +lime:0 +raspberries:0 +cantaloupe:0 +tangerine:0 +figs:0 +oranges:0 +bananas:0 +potatoes:0 +potato:0 +butter:1 +cheese:1 +cottage cheese:1 +non-fat dairy creamer:1 +milk:1 +skim milk:1 +2% milk:1 +two percent milk:1 +whole milk:1 +dairy spreads:1 +cream cheese:1 +powdered milk:1 +yogurt:1 +pudding:1 +frozen yogurt:1 +ice milk:1 +low fat milk:1 +ice cream:1 +milk:1 +coke:1 +sprite:1 +pepsi:1 +mountain dew:1 +apple juice:1 +orange juice:1 +grape juice:1 +strawberry juice:1 +chinola juice:1 +starfruit juice:1 +mango juice:1 +cereals:1 +bread:1 +english muffins:1 +toast:1 +sandwiches:1 +triscuits:1 +wheat thins:1 +crackers:1 +oatmeal:1 +cream of wheat:1 +corn:1 +corn syrup:1 +high-fructose corn syrup:1 +wheat:1 +pancakes:1 +hash browns:1 +beer:1 +pasta:1 +fettuchini:1 +lasagne:1 +lasagna:1 +black beans:1 +broad beans:1 +fava beans:1 +garbanzo beans:1 +horse beans:1 +kidney beans:1 +lima beans:1 +mung beans:1 +adzuki beans:1 +navy beans:1 +pinto beans:1 +red beans:1 +green beans:1 +string beans:1 +white beans:1 +beans:1 +peas:1 +black-eyed peas:0 +chickpeas:1 +snowpeas:1 +sugar snap peas:1 +peanuts:1 +peanut butter:1 +miso:1 +lentils:1 +lupins:1 +mesquite:1 +soybeans:1 +soybean:1 +tofu:1 +beans:1 +acesulfame potassium:1 +ack:1 +ace k:1 +equal spoonful:1 +sweet one:1 +sunett:1 +aspartame:1 +apm:1 +aminosweet:1 +aspartyl-phenylalanine-1-methyl ester:1 +canderel:1 +equal classic:1 +natrataste blue:1 +nutrasweet:1 +aspartame-acesulfame salt:1 +twinsweet:1 +cyclamate:1 +calcium cyclamate:1 +cologran:1 +cyclamate and saccharin:1 +sucaryl:1 +erythritol:1 +sugar alcohol:1 +zerose:1 +zsweet:1 +glycerol:1 +glycerin:1 +glycerine:1 +glycyrrhizin:1 +licorice:1 +hydrogenated starch hydrolysate:1 +hsh:1 +sugar alcohol:1 +isomalt:1 +sugar alcohol:1 +clearcut isomalt:1 +decomalt:1 +diabetisweet:1 +hydrogenated isomaltulose:1 +isomaltitol:1 +lactitol:1 +sugar alcohol:1 +maltitol:1 +sugar alcohol:1 +maltitol syrup:1 +maltitol powder:1 +hydrogenated high maltose content glucose syrup:1 +hydrogenated maltose:1 +lesys:1 +maltisweet:1 +sweetpearl:1 +mannitol:1 +sugar alcohol:1 +neotame:1 +polydextrose:1 +sugar alcohol:1 +saccharin:1 +acid saccharin:1 +equal saccharin:1 +necta sweet:1 +sodium saccharin:1 +sweet n low:1 +sweet twin:1 +sorbitol:1 +sugar alcohol:1 +d-glucitol:1 +d-glucitol syrup:1 +steviol glycoside:1 +rebiana:1 +sucralose:1 +trichlorosucrose:1 +equal sucralose:1 +natrataste gold:1 +splenda:1 +tagatose:1 +natrulose:1 +xylitol:1 +sugar alcohol:1 +smart sweet:1 +xylipure:1 +xylosweet:1 +spam:1 +hot dogs:1 +french fries:1 +ketchup:1 +pretzels:1 +chips:1 +triscuits:1 +wheat thins:1 +cookies:1 +sunchips:1 +pastries:1 +red bull:1 +monster:1 +rockstar:1 +starbucks refreshers:1 +mountain dew mdx:1 +vault:1 +xs energy drink:1 +5-hour energy:1 +beer:1 +whiskey:1 +tequila:1 +rum:1 +vodka:1 +alcohol and mixers:1 +candy bars:1 +snickers:1 +snickers peanut butter:1 +100 grand:1 +butterfinger:1 +milky way:1 +reese’s:1 +payday:1 +m&ms:1 +skittles:1 +red vines:1 +twizzlers:1 +hershey’s:1 +nestle crunch:1 +almond joy:1 +mounds:1 +reese’s fast break:1 +reeses’s pieces:1 +twix:1 +twix peanut butter:1 \ No newline at end of file diff --git a/share/goodie/paleo_ingredient_check/triggers.txt b/share/goodie/paleo_ingredient_check/triggers.txt deleted file mode 100644 index c2827e401..000000000 --- a/share/goodie/paleo_ingredient_check/triggers.txt +++ /dev/null @@ -1,14 +0,0 @@ -paleo friendly -paleo friendly? -paleo diet friendly -paleo diet friendly? -paleo safe -paleo safe? -paleo -paleo? -allowed on the paleo diet -allowed on the paleo diet? -allowed on paleo diet -allowed on paleo diet? -allowed on paleo -allowed on paleo? \ No newline at end of file diff --git a/share/goodie/paleo_ingredient_check/unsafe.txt b/share/goodie/paleo_ingredient_check/unsafe.txt deleted file mode 100644 index d162e75da..000000000 --- a/share/goodie/paleo_ingredient_check/unsafe.txt +++ /dev/null @@ -1,208 +0,0 @@ -butter -cheese -cottage cheese -non-fat dairy creamer -milk -skim milk -2% milk -two percent milk -whole milk -dairy spreads -cream cheese -powdered milk -yogurt -pudding -frozen yogurt -ice milk -low fat milk -ice cream -milk -coke -sprite -pepsi -mountain dew -apple juice -orange juice -grape juice -strawberry juice -chinola juice -starfruit juice -mango juice -cereals -bread -english muffins -toast -sandwiches -triscuits -wheat thins -crackers -oatmeal -cream of wheat -corn -corn syrup -high-fructose corn syrup -wheat -pancakes -hash browns -beer -pasta -fettuchini -lasagne -lasagna -black beans -broad beans -fava beans -garbanzo beans -horse beans -kidney beans -lima beans -mung beans -adzuki beans -navy beans -pinto beans -red beans -green beans -string beans -white beans -beans -peas -black-eyed peas -chickpeas -snowpeas -sugar snap peas -peanuts -peanut butter -miso -lentils -lupins -mesquite -soybeans -soybean -tofu -beans -acesulfame potassium -ack -ace k -equal spoonful -sweet one -sunett -aspartame -apm -aminosweet -aspartyl-phenylalanine-1-methyl ester -canderel -equal classic -natrataste blue -nutrasweet -aspartame-acesulfame salt -twinsweet -cyclamate -calcium cyclamate -cologran -cyclamate and saccharin -sucaryl -erythritol -sugar alcohol -zerose -zsweet -glycerol -glycerin -glycerine -glycyrrhizin -licorice -hydrogenated starch hydrolysate -hsh -sugar alcohol -isomalt -sugar alcohol -clearcut isomalt -decomalt -diabetisweet -hydrogenated isomaltulose -isomaltitol -lactitol -sugar alcohol -maltitol -sugar alcohol -maltitol syrup -maltitol powder -hydrogenated high maltose content glucose syrup -hydrogenated maltose -lesys -maltisweet -sweetpearl -mannitol -sugar alcohol -neotame -polydextrose -sugar alcohol -saccharin -acid saccharin -equal saccharin -necta sweet -sodium saccharin -sweet n low -sweet twin -sorbitol -sugar alcohol -d-glucitol -d-glucitol syrup -steviol glycoside -rebiana -sucralose -trichlorosucrose -equal sucralose -natrataste gold -splenda -tagatose -natrulose -xylitol -sugar alcohol -smart sweet -xylipure -xylosweet -spam -hot dogs -french fries -ketchup -pretzels -chips -triscuits -wheat thins -cookies -sunchips -pastries -red bull -monster -rockstar -starbucks refreshers -mountain dew mdx -vault -xs energy drink -5-hour energy -beer -whiskey -tequila -rum -vodka -alcohol and mixers -candy bars -snickers -snickers peanut butter -100 grand -butterfinger -milky way -reese’s -payday -m&ms -skittles -red vines -twizzlers -hershey’s -nestle crunch -almond joy -mounds -reese’s fast break -reeses’s pieces -twix -twix peanut butter \ No newline at end of file