Skip to main content

Recipe Tagger

This package provides a classification, a tagging system and a water footprint calculator for ingredients and recipes.
The functioning of the package is based on a dataset containing more than 700 ingredients mapped with their own class and water footprint. If a provided ingredient is not mapped into the dataset, the library search for it on wikipedia pages, into the dictionary and into NLTK Wordnet to find the best possible class. The water footprint is computed based on its ingredients. Every ingredient has a water footprint, measured in l/kg.

An ingredient could be classified in one of the following class:

  • Vegetable
  • Fruit
  • Legume
  • Meat
  • Egg
  • Diary
  • Staple
  • Condiment
  • Nut
  • Seafood
  • Snack
  • Mushroom
  • Dessert
  • Beverage

A recipe is tagged based on its ingredients class. The library also provides a function to get the class percentage of recipe ingredients.

Installation

pip install recipe_tagger

Recipe Tagger module

How to use

from recipe_tagger import recipe_tagger

Get the class of a single ingredient

recipe_tagger.get_ingredient_class('aubergine')
# vegetable

Get tags of a recipe (it is needed to provide all the ingredient of the recipe)

recipe_tagger.get_recipe_tags(['aubergine', 'chicken'])
# ['vegetable', 'meat']

Get class percentage of a recipe (it is needed to provide all the ingredient of the recipe)

recipe_tagger.get_recipe_class_percentage(['aubergine', 'chicken', 'beef'])
# [('vegetable', '33.33%'), ('meat', '66.67%')]

Recipe Water Footprint module

How to use

from recipe_tagger import recipe_waterfootprint as wf

Get the water footprint of a single ingredient

wf.get_ingredient_waterfootprint("tomato", 20, process=True, language="en")
# 4.28

Get the water footprint of a recipe (it is needed to prived all the ingredients and the quantity of the recipe)

In order to provide a precise calculation of the WF, it is needed to provide also the quantity used for the ingredient in the recipe. Quanities must be provided matching the following pattern: "{number}{unit}". Unit can be one of ml, gr, kg, l, ounce, teaspoon, tablespoon, cup, pint quart, gallon, pound, clove, lb, or their abbreviation.

wf.get_recipe_waterfootprint(
            ["tomato", "apple", "chicken"], 
            ["20gr", "5ml", "1l"], 
            language="en")
# 4329.28

Get the water footprint of a recipe and informations about the ingredients water footprint

wf.get_recipe_waterfootprint(
            ["tomato", "apple", "chicken"],
            ["20gr", "5ml", "1l"],
            language="en",
            information=True,
        )
# (4329.28, {"tomato": 4.28, "apple": 0.0, "chicken": 4325.0})

Language support

Every method of the package provide the language support. Use the "language" parameter along with the abbreviation of a supported language. Default language is English, if the "language" argument is not provided.

  • English ("en")
  • Italian ("it")

Todo

  • Handling of Wikipedia pages.
  • Better search over dictionary and Wikipedia pages of ingredient.
  • Calculate the water foorprint of a recipe
  • Add the possibility to add an ingredient after search if it is not present into the embedding.
  • An explanation in order to provided an other language.
  • A method for automatic translation when providing another language.

Release files for recipe-tagger 0.4.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for recipe-tagger 0.4.13
File Size Uploaded
recipe-tagger-0.4.13.tar.gz 35.0 kB Details

Release files / recipe-tagger-0.4.13.tar.gz

Download URL recipe-tagger-0.4.13.tar.gz
Size 35.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8e67bd3f9c9bd0167d495838b44bf2bdfa418f8b6893bfcf52fc17301bf583a2
BLAKE2b-256 checksum
How to use checksums
e7351ad56d523d4ef84904689a44b051bda93bca75d8bf3fc96ce2af207d8e84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.12

Release history Release notifications | RSS feed

This release

0.4.13 This release

1 release file

0.4.12

1 release file

0.4.11

1 release file

0.4.10

1 release file

0.4.9

1 release file

0.4.8

1 release file

0.4.7

1 release file

0.4.6

1 release file

0.4.5

1 release file

0.4.4

1 release file

0.4.3

1 release file

0.4.2

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.10

1 release file

0.3.9

1 release file

0.3.8

1 release file

0.3.7

1 release file

0.3.6

1 release file

0.3.5

1 release file

0.3.4

1 release file

0.3.3

1 release file

0.3.2

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page