foodemoji

Decorate a German text (e.g. restaurant menu) with food specific emojis

Source on Github

Example

>>> import foodemoji
>>> text = """Hähnchenbrust mit Apfelrotkraut
Vegetarische Maultaschen
Kartoffelknödel
Paniertes Schnitzel mit Pommes frites
Rinderbraten, Rotweinsauce und Spätzle"""

>>> print(foodemoji.decorate(text))
"""Hähnchenbrust :rooster: mit Apfelrotkraut :red_apple:
Vegetarische :green_heart: Maultaschen
Kartoffelknödel :potato:
Paniertes Schnitzel mit Pommes frites :french_fries:
Rinderbraten :cow:, Rotweinsauce :wine_glass: und Spätzle"""

>>> import emoji
>>> print(emoji.emojize(foodemoji.decorate(text)))
"""Hähnchenbrust 🐓 mit Apfelrotkraut 🍎
Vegetarische 💚 Maultaschen
Kartoffelknödel 🥔
Paniertes Schnitzel mit Pommes frites 🍟
Rinderbraten 🐮, Rotweinsauce 🍷 und Spätzle"""

>>> text2 = """Gegrillte Hähnchenbrust mit gekochter Hähnchenbrust
Gebratenes Hähnchen mit Hähnchenschnitzel"""
>>> print(foodemoji.decorate(text2))
"""Gegrillte Hähnchenbrust :rooster: mit gekochter Hähnchenbrust :rooster:
Gebratenes Hähnchen :rooster: mit Hähnchenschnitzel :rooster:"""

>>> print(foodemoji.decorate(text2, line_by_line=True))
"""Gegrillte Hähnchenbrust mit gekochter Hähnchenbrust :rooster:
Gebratenes Hähnchen mit Hähnchenschnitzel :rooster:"""

Install

pip install german-foodemoji

See: https://pypi.org/project/german-foodemoji/

Requirements

  • Python 3.7+

To actually print the unicode emojis and for the units tests the package emoji>=2.1.0 is required:

pip install emoji

Functions

foodemoji.decorate(text, line_by_line=False)[source]

Decorate text with food-specific emoji in the form ‘:emoji_name:’

Parameters:
  • text (str) – the text to decorate

  • line_by_line (bool) – if true the text is decorated line by line and an emoji can only occur once per line.

Returns:

the decorated text

Return type:

str

Raises:

TypeError – If the text is not a unicode string and not pure ascii (Only Python 2.x)

foodemoji.decorate_whole(text)[source]
Decorates text with food-specific emojis
  • Whole text at once approch

  • Emoji can occur several times per line

Parameters:

text (unicode) – the text to decorate

Returns:

the decorated text

Return type:

unicode

foodemoji.decorate_lines(text)[source]
Decorates text with food-specific emojis
  • Line by line approch

  • An emoji can only occur once per line (last occurunce)

Parameters:

text (unicode) – the text to decorate

Returns:

the decorated text

Return type:

unicode

foodemoji._load()[source]

Load from foodemojis.json file and compile regular expressions. Automatically called on first use decorate()

raises re.error:

if the message_body is not a basestring

Supported emojis and patterns

foodemojis.json
{
    ":fish:" : ["(?<!lachs)forelle","lachs","karpfen","hecht", "barsch(\\s+|$|filet)", "makrele", "kabeljau", "(\\b|\\s|^)aal",
               "dorsch", "pangasius", "(\\b|\\s|^)tuna", "hering", "saibling", "zander", "wels", 
               "flunder", "(?<!rha)barbe(\\b|\\s+|$)", "butt(?!er)", "scholle","seezunge", "tilapia", "scharbe", "dorade",
               "eisflunder", "lotte[^n]", "seeteufel",  "steinbeißer", "skantjes", "(\\b|\\s|^)hoki", "merlan", "wittling",
               "matjes", "schlemmerfilet", "(?<!tinten)fisch", "([^\\:]|^)fish"],
    ":squid:" : ["tintenfisch", "calamari", "calamares", "kalmar", "chipirones"],
    ":lobster:" : ["hummer"],
    ":oyster:" : ["austern?", "hu[îi]tres", "sylter\\s*royal"],
    ":shark:" : ["chillerlocke", "seeaal"],
    ":octopus:" : ["oktopus", "pulpo","kraken"],
    ":fried_shrimp:" : ["(?<!fried_)shrimp","garnelen","krebs","krabbe"],
    ":cow:" : ["[^t]rind", "kalb", "strogano\\w{1,2}", "tafelspitz", "entrec\\wte", "rumpsteak", "ossobuco", "tatar"],
    ":pig:" : ["(?<!wild)schwein","pork", "minutensteak", "(\\b|\\s|^)krustenbraten", "kasse?ler", "currywurst", 
              "(?<!kalbs)bratwurst", "fleischkäs", "spare-?\\s*rips", "krakauer", "schäuf[ae]r?l[ae]", "eisbein", 
              "hachse", "hax[en]", "mettwurst", "mettend", "mettend"],
    ":cut_of_meat:" : ["(?<!soja)steak", "kotelett", "rippchen", "roastbeef", "entrec\\wte"],
    ":horse:" : ["pferd"],
    ":boar:" : ["wildschwein"],
    ":goat:" : ["ziegen"],
    ":deer:" : ["hirsch","(\\b|\\s|^)reh"],
    ":rabbit:" : ["hasen"],
    ":kangaroo:" : ["känguru"],
    ":ewe:" : ["(\\b|\\s|^)lamm","lämmer","hammel", "schaf[^ft]"],
    ":rooster:" : ["huhn","geflügel","hähnchen","hühn", "hendl", "broiler", "chicken", "coq"],
    ":turkey:" : ["truthahn","pute([^r]|$)","[^(\\:|_)]turkey"],
    ":duck:" : ["(\\b|\\s|^)ente"],
    ":goose:" : ["gans", "gänse"],
    ":panda:" : ["bambus"],
    ":broccoli:" : ["brokkoli", "([^\\:]|^)broccoli"],
    ":leafy_green:" : ["p[ao]k(\\s|-)?cho[iy]", "chinakohl", "mangold"],
    ":coconut:" : ["kokos", "cocos"],
    ":mushroom:" : ["pilz", "schwammerl", "champignon", "pfifferling", "morcheln", "kräuterseitling", "shiitake"],
    ":tangerine:" : ["orange","mandarine","apfelsine"],
    ":lemon:" : ["([^\\:]|^)lemon", "zitrone", "limone"],
    ":peach:" : ["pfirsis?ch", "nektarine", "aprikose"],
    ":mango:" : ["([^\\:]|^)mango(?!ld)", "mangue"],
    ":pretzel:" : ["brez[en]"],
    ":baguette_bread:" : ["baguette(\\b|\\s|$)", "ciabatta"],
    ":grapes:" : ["\\btrauben"],
    ":blueberries:" : ["blaubeer", "heidelbeer", "schwarzbeer", "([^\\:]|^)blueberr[yi]"],
    ":watermelon:" : ["wassermelone"],
    ":tomato:" : ["tomate","pomodor", "tomatisiert"],
    ":strawberry:" : ["erdbeer", "fraisier", "fraise"],
    ":banana:" : ["banane"],
    ":cherries:" : ["kirsch(?!(\\s|-)?tomaten)"],
    ":wine_glass:" : ["(?<!(eiß|sch))wein", "riesling", "burgunder"],
    ":mate:" : ["(-|\\s)mate(\\b|\\s|$)"],
    ":eggplant:" : ["aubergine", "baba(\\s|-)?ghanoush", "mo?uss?ak(a|á)s?", "(İm|i̇m)bayıldı", "imam ba(y|i)ildi", "melanzane"],
    ":ear_of_corn:" : ["mais(?!on)","polenta"],
    ":carrot:" : ["karotte","möhre","gelbe rübe"],
    ":onion:" : ["([^\\:]|^)onion", "zwiebel"],
    ":cucumber:" : ["gurke"],
    ":peanuts:" : ["erdn[uü]ss"],
    ":potato:" : ["(?<!süß)kartoffel", "([^\\:]|^)potato([^\\:]|^)", "patatas", "reibekuchen", "rösti(\\s*|-)?ecken", "criss(\\s*|-?)cuts"],
    ":jack-o-lantern:" : ["kürbis", "pumpkin"],
    ":roasted_sweet_potato:" : ["süßkartoffel"],
    ":honey_pot:" : ["honig", "([^\\:]|^)honey", "(\\b|\\s|^)miel"],
    ":poultry_leg:" : ["schlegel", "keule", "eisbein", "hachse", "hax[en]"],
    ":cheese_wedge:" : ["([^\\:]|^)cheese", "(?<!fleisch)käse", "fromage", "gouda", "gorgonzola", "mozzarella", "formaggi", "parmesan(?!k)",
                       "grana padano", "ricotta", "cordon bleu", "camembert"],
    ":pizza:" : ["([^\\:]|^)pizza", "lahmacun"],
    ":hamburger:" : ["(?<!\\:ham)burger"],
    ":fondue:" : ["([^\\:]|^)fondue", "hot pot"],
    ":burrito:" : ["([^\\:]|^)burrito","([^\\:]|^)wrap","fajita","dürüm"],
    ":falafel:" : ["([^\\:]|^)f[ea]lafel"],
    ":tamale:" : ["([^\\:]|^)tamal", "chuchito", "guanim"],
    ":curry_rice:" : ["([^\\:]|^)curry(?!(wurst)|(-?sauce)|(-?soße)|(-?dip))"],
    ":french_fries:" : ["pommes frites", "pommes(?!(\\s|-)frites)", "twisters", "chips"],
    ":flatbread:" : ["fladenbrot", "tortilla", "piadin[ai]"],
    ":taco:" : ["([^\\:]|^)taco([^\\:]|^)", "quesadilla"],
    ":stuffed_flatbread:" : ["döner", "pita", "pide"],
    ":green_salad:" : ["(?<!wurst)salat", "salade"],
    ":dumpling:" : ["empanada", "maultasche", "pelmen", "pirogge", "pierogi", "schlickkrapfen", "schlutzkrapfen", "ravioli", 
                   "tortelloni","tortellini", "cappelletti", "sacchettoni"],
    ":bacon:" : ["([^\\:]|^)bacon","speck", "jambon"],
    ":spaghetti:" : ["([^\\:]|^)spaghetti","pasta","penne","tagliatelle","spirelli","farfalle","makkaroni", 
                    "maccheroni", "bucatini"],
    ":cooked_rice:" : ["risotto", "gemüsereis", "kräuterreis", "jasminreis", "sushireis", 
                      "wildreis", "mochireis", "kurkumareis", "butterreis", "basmatireis", 
                      "kornreis", "naturreis", "milchreis", "duftreis", "risi(-|\\s)?(p|b)isi",
                      "ingwerreis", "pfannenreis", "djuvecreis", "parboiledreis", "pila[fw]", "(^|\\s)reis($|\\b)"],
    ":bento_box:" : ["sushi","([^\\:]|^)bento"],
    ":shortcake:" : ["(\\b|\\s|^)kuchen","torte(?!(llini|lloni))"],
    ":cookie:" : ["keks","([^\\:]|^)cookie"],
    ":pancakes:" : ["cr.pe", "eierkuchen", "palatschinken", "pfannkuchen", "rührei", "omelett", "(\\w|\\s|^)pancake(\\s|$|\\w)"],
    ":chocolate_bar:" : ["schoko", "([^\\:]|^)chocolat"],
    ":ice_cream:" : ["(\\b|\\s|^)eis(\\b|\\s|$)", "eisbecher", "vanilleeis"],
    ":bagel:" : ["([^\\:]|^|\\b|\\s)bagel([^:]|$)"],
    ":doughnut:" : ["([^\\:]|^|\\b|\\s)doughnut([^:]|$)", "donut"],
    ":waffle:" : ["waffeln?"],
    ":cupcake:" : ["([^\\:]|^|\\b|\\s)cupcake([^:]|$)"],
    ":croissant:" : ["([^\\:]|^)croissant"],
    ":hot_beverage:" : ["kaffee", "cappuccino"],
    ":butter:" : ["([^\\:]|^)butter"],
    ":beer_mug:" : ["bier(\\b|\\s)", "bierteig", "biersauce", "biersoße", "braumeister"],
    ":wrapped_gift:" : ["überraschung"],
    ":avocado:" : ["([^\\:]|^)avocado","guacamole"],
    ":beans:" : ["bohnen"],
    ":pea_pod:" : ["erbsen"],
    ":kiwi_fruit:" : ["(\\s|^|\\w)kiwi"],
    ":pineapple:" : ["ananas", "piña"],
    ":red_apple:" : ["apfel","äpfel"],
    ":pear:" : ["birne"],
    ":olive:" : ["oliven"],
    ":chestnut:" : ["maronen", "maroni", "kastanien", "marrons?"],
    ":glass_of_milk:" : ["(\\b|\\s|^)milch(\\b|\\s|$)"],
    ":victory_hand:" : ["vegan"],
    ":green_heart:" : ["vegetarisch"],
    ":custard:" : ["flan(\\s+|$)", "karamell?(\\s|-)?pudding", "karamell?(\\s|-)?creme", "cr.me br.l.{1,2}", "cr\\wme (c|k)aramell?", "crema catalana","crema cremada","brönnti"],
    ":hot_pepper:" : ["chill?i","pepp?eroni", "chil?potle"],
    ":bell_pepper:" : ["paprika"],
    ":fire:" : ["feuer" ,"feurig"],
    ":smiling_face_with_horns:" : ["dia[bv]olo", "teufel","teufli"],
    ":shallow_pan_of_food:" : ["pfanne"],
    ":steaming_bowl:" : ["suppe", "\\bramen", "klare\\s*brühe", "bouillon", "gemüse\\s*brühe", "minestrone"],
    ":dragon:" : ["asia"],
    ":garlic:" : ["knoblauch", "aioli", "([^\\:]|^)garlic"],
    ":ginger_root:": ["([^\\:]|^)ginger", "ingwer"],
    ":smiling_face_with_halo:" : ["fair\\s*trade"],

    ":flag_for_Greece:" : ["griechisch", "gyros", "tzatziki", "tsatsiki", "bifteki", "so?u(f|v)laki", "rhodos", "gebackener feta", "patros"],
    ":flag_for_Indonesia:" : ["indonesisch","goreng","satay","saté(\\s|-|s)","(\\s|^|\\w)sate(\\s|-|s)"],
    ":flag_for_Serbia:" : ["serbisch" ,"\\wevap\\wi\\wi"],
    ":flag_for_Hungary:" : ["ungarisch", "szeged", "esterh\\wzy", "gulaschsuppe", "pörkölt"],
    ":flag_for_United_Kingdom:" : ["englisch"],
    ":flag_for_India:" : ["(^|[^k])indisch", "aloo(\\s|-)?gobi", "samosa", "raita", "kanpur", "punjabi", "tandoori","tikka(\\s|-)?masala"],
    ":flag_for_Thailand:" : ["[^_]thai","khao","keng","tom(\\s|-)?yam"],
    ":flag_for_France:" : ["französisch", "proven\\wi?al", "els[aä]ss", "korsisch", "pot(\\s|-)?au(\\s|-)?feu", "cassoulet"],
    ":flag_for_United_States:" : ["((nord-?)|\\s+)amerikanisch","[^_]georgia","st. louis", "america"],
    ":flag_for_China:" : ["chinesisch", "kanton", "[^_]china(?!(\\s|-)?kohl)", "wan(\\s|-)?tan", "chop(\\s|-)?suey","kung(\\s|-)?pa?o", "szechuan", "peking", "shanghai", "feng(\\s|-)?shui"],
    ":flag_for_Hong_Kong:" : ["hong kong"],
    ":flag_for_Japan:" : ["japanisch", "sushi", "teriyaki", "shabu(\\s|-)?shabu", "miso"],
    ":flag_for_Turkey:" : ["türkisch", "döner","yufka","lahmacun","börek"],
    ":flag_for_Italy:" : ["italienisch", "italiano", "calabria", "toskan", "florentiner", "lasagne", "gnocchi", "bolognese", "cannelloni", "linguin"],
    ":flag_for_Spain:" : ["spanisch", "bravas", "arrugadas", "pa\\wlla", "arroz", "gazpacho", "empanada"],
    ":flag_for_Poland:" : ["polnisch"],
    ":flag_for_Mexico:" : ["[^_]mexi(c|k)"],
    ":flag_for_Argentina:" : ["[^_]argentin"],
    ":flag_for_Brazil:" : ["brasili"],
    ":flag_for_Chile:" : ["[^_]chile"],
    ":flag_for_Peru:" : ["[^_]peru"],
    ":flag_for_Netherlands:" : ["holländisch", "niederländisch","flämisch"],
    ":flag_for_Sweden:" : ["swedisch", "köttbullar"],
    ":flag_for_Egypt:" : ["ägyptisch"],
    ":flag_for_Tunisia:" : ["tunesisch", "minztee"],
    ":flag_for_Algeria:" : ["algerisch"],
    ":flag_for_Morocco:" : ["marokkanisch"],
    ":flag_for_Azerbaijan:" : ["aserbaidschan"],
    ":flag_for_Belarus:" : ["weißrussisch"],
    ":flag_for_Russia:" : ["(?<!weiß)russisch"],
    ":flag_for_Bulgaria:" : ["bulgarisch"],
    ":flag_for_Bosnia_&_Herzegovina:" : ["bosnisch"],
    ":flag_for_Czech_Republic:" : ["tschechisch"],
    ":flag_for_Denmark:" : ["dänisch"],
    ":flag_for_Iran:" : ["iranisch" ,"persisch"],
    ":flag_for_Finland:" : ["finnisch"],
    ":flag_for_Faroe_Islands:" : ["färöisch"],
    ":flag_for_Switzerland:" : ["schweiz", "tessin", "zürich"],
    ":flag_for_Austria:" : ["österreich", "tirol", "kärnten", "steiermark", "kaiserschmarre?n", "germknödel", "linzer\\s*torte", "apfelstrudel"],
    ":flag_for_Israel:" : ["hebräisch", "koscher"],
    ":flag_for_Croatia:" : ["kroatisch", "[^_]croatia"],
    ":flag_for_Armenia:" : ["armenisch"],
    ":flag_for_Iceland:" : ["isländisch"],
    ":flag_for_Georgia:" : ["georgisch"],
    ":flag_for_Canada:" : ["kanadisch", "ahorn"],
    ":flag_for_Luxembourg:" : ["luxemburg"],
    ":flag_for_Mongolia:" : ["mongolisch"],
    ":flag_for_Norway:" : ["norwegisch", "kjøttboller", "kjøttkaker"],
    ":flag_for_Portugal:" : ["portugiesisch"],
    ":flag_for_Romania:" : ["rumänisch"],
    ":flag_for_Slovakia:" : ["slowakisch"],
    ":flag_for_Slovenia:" : ["slowenisch"],
    ":flag_for_Somalia:" : ["[^_]somali"],
    ":flag_for_Albania:" : ["albanisch"],
    ":flag_for_Syria:" : ["syrisch"],
    ":flag_for_Ukraine:" : ["ukrainisch", "borschtsch"],
    ":flag_for_Vietnam:" : ["[^_]vietnam"],
    ":flag_for_Philippines:" : ["[^_]philippin"],
    ":flag_for_South_Korea:" : ["[^_]korea", "kimchi", "jjigae"],

    ":face_with_medical_mask:" : ["edumask", "maske"]
}

Indices and tables