1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-07-19 13:19:41 +02:00

fix(deps): update dependency ingredient-parser-nlp to v2 (#5137)

This commit is contained in:
Michael Genson 2025-02-28 09:51:36 -06:00 committed by GitHub
parent 61ae6b3e32
commit cfba2fff7e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 148 additions and 16 deletions

View file

@ -1,3 +1,5 @@
from fractions import Fraction
from ingredient_parser import parse_ingredient from ingredient_parser import parse_ingredient
from ingredient_parser.dataclasses import CompositeIngredientAmount, IngredientAmount from ingredient_parser.dataclasses import CompositeIngredientAmount, IngredientAmount
from ingredient_parser.dataclasses import ParsedIngredient as IngredientParserParsedIngredient from ingredient_parser.dataclasses import ParsedIngredient as IngredientParserParsedIngredient
@ -54,7 +56,9 @@ class NLPParser(ABCIngredientParser):
@staticmethod @staticmethod
def _extract_amount(ingredient: IngredientParserParsedIngredient) -> IngredientAmount: def _extract_amount(ingredient: IngredientParserParsedIngredient) -> IngredientAmount:
if not (ingredient_amounts := ingredient.amount): if not (ingredient_amounts := ingredient.amount):
return IngredientAmount(quantity=0, quantity_max=0, unit="", text="", confidence=0, starting_index=-1) return IngredientAmount(
quantity=Fraction(0), quantity_max=Fraction(0), unit="", text="", confidence=0, starting_index=-1
)
ingredient_amount = ingredient_amounts[0] ingredient_amount = ingredient_amounts[0]
if isinstance(ingredient_amount, CompositeIngredientAmount): if isinstance(ingredient_amount, CompositeIngredientAmount):
@ -67,12 +71,15 @@ class NLPParser(ABCIngredientParser):
confidence = ingredient_amount.confidence confidence = ingredient_amount.confidence
if isinstance(ingredient_amount.quantity, str): if isinstance(ingredient_amount.quantity, str):
return extract_quantity_from_string(ingredient_amount.quantity)[0], confidence qty = extract_quantity_from_string(ingredient_amount.quantity)[0]
else: else:
try: try:
return float(ingredient_amount.quantity), confidence qty = float(ingredient_amount.quantity)
except ValueError: except ValueError:
return 0, 0 qty = 0
confidence = 0
return qty, confidence
@staticmethod @staticmethod
def _extract_unit(ingredient_amount: IngredientAmount) -> tuple[str, float]: def _extract_unit(ingredient_amount: IngredientAmount) -> tuple[str, float]:
@ -82,8 +89,13 @@ class NLPParser(ABCIngredientParser):
@staticmethod @staticmethod
def _extract_food(ingredient: IngredientParserParsedIngredient) -> tuple[str, float]: def _extract_food(ingredient: IngredientParserParsedIngredient) -> tuple[str, float]:
confidence = ingredient.name.confidence if ingredient.name else 0 if not ingredient.name:
food = str(ingredient.name.text) if ingredient.name else "" return "", 0
ingredient_name = ingredient.name[0]
confidence = ingredient_name.confidence
food = ingredient_name.text
return food, confidence return food, confidence
@staticmethod @staticmethod

121
poetry.lock generated
View file

@ -733,6 +733,53 @@ typing-extensions = "*"
[package.extras] [package.extras]
test = ["pytest", "pytest-cov", "pytest-mpl", "pytest-subtests"] test = ["pytest", "pytest-cov", "pytest-mpl", "pytest-subtests"]
[[package]]
name = "floret"
version = "0.10.5"
description = "floret Python bindings"
optional = false
python-versions = "*"
groups = ["main"]
files = [
{file = "floret-0.10.5-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:50c2f950dbfffd6ff32525a4dc902cff94c9530d68bc14b6a7d27e363ffaf8df"},
{file = "floret-0.10.5-cp310-cp310-macosx_11_0_x86_64.whl", hash = "sha256:f3d78f7a0da75a7d6481db1a6b6d5c495caa558f52fcaa7800b05b013518732f"},
{file = "floret-0.10.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f70107549c9811a3d36d7ad184ee2eb69800d5fd652ed09e7ec9e9b51b82ab9a"},
{file = "floret-0.10.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1a6dc625a66f3fe4fa2976585cb33f90584f58995197325ac179a01a3faa4fea"},
{file = "floret-0.10.5-cp310-cp310-win_amd64.whl", hash = "sha256:009a80bd3d92915c02d2c2cc985fc602fa6ccb9e012a9d17b77a0d9baeb14dc2"},
{file = "floret-0.10.5-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:9b7b9a6aaf807a0ed0a0d3615206b67f46b56f52a94dcdc50d7412b40b76418a"},
{file = "floret-0.10.5-cp311-cp311-macosx_11_0_x86_64.whl", hash = "sha256:1a6c7cec76c545a181f1b4987988871dba8fd5966b760b66f7e79f4c4565ef94"},
{file = "floret-0.10.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:17d12b5e195a1220b9b173647ba215cb680fd82f5f5f9e68a34a9dc16c27d491"},
{file = "floret-0.10.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:237e2eeee54147bf893aef8b1297631f53127b888c2978b1957d9a96af9b769c"},
{file = "floret-0.10.5-cp311-cp311-win_amd64.whl", hash = "sha256:020317dac154caff1e03cdb8dd1e5d013cb0749d5913e264834017386f905655"},
{file = "floret-0.10.5-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:87bb2d7a44c6ac2572ca4aeed6a7780f184c2cebe67a6cf3e3b8d3005da360b4"},
{file = "floret-0.10.5-cp312-cp312-macosx_11_0_x86_64.whl", hash = "sha256:96de360cf7f93f21e28641f74c309e3207ceab3856b2cf4867f9135788f02115"},
{file = "floret-0.10.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7c3d1d189fd12f75bc2f4229a5fd4f6eb333f598063609ff050c6a1296568e98"},
{file = "floret-0.10.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dfea32120951b8781c318e5ee9847eb9895ff7a18dd49c5d466ad8951589a0f5"},
{file = "floret-0.10.5-cp312-cp312-win_amd64.whl", hash = "sha256:e074b9e731504191e366f5f21f2f419a2dc3194d6d17ef26ced7edceefac3f79"},
{file = "floret-0.10.5-cp36-cp36m-macosx_10_16_x86_64.whl", hash = "sha256:c2ba155ce1dd704c0424fa2ce0118ffde4418ee3785d7dbeda3a1a0e13f009ac"},
{file = "floret-0.10.5-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e9a905fe7e46e48634835681256afa3e296b6b7350c1939c70e73c221f009d99"},
{file = "floret-0.10.5-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:994993a16675c33eeec561f32b2233dff8e39267c426a510c01158612fbde4b8"},
{file = "floret-0.10.5-cp36-cp36m-win_amd64.whl", hash = "sha256:7ea662bab1db425c07a969a0efc41747e05daf50fe24fffeb7661360961ce44f"},
{file = "floret-0.10.5-cp37-cp37m-macosx_10_16_x86_64.whl", hash = "sha256:088006325cba178fd725745ea2d935985723f7bc40762bbbd9e518188774de40"},
{file = "floret-0.10.5-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b438963856a4903732309a3319f0681806a3bf084651354daa5b3265f4c64380"},
{file = "floret-0.10.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a29128c874c3c453729e89783f667d62235d609c926c644f3d48503fed93ff61"},
{file = "floret-0.10.5-cp37-cp37m-win_amd64.whl", hash = "sha256:b5b58fac25bab7b513e350a122270ed5637da6179a98e36939f934d82385ac6b"},
{file = "floret-0.10.5-cp38-cp38-macosx_10_16_x86_64.whl", hash = "sha256:63c649375187e3ae5fa7921527f6c44eedba618ab9d2b4047d05a1d501e93dd4"},
{file = "floret-0.10.5-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:f213a01af2bd9f1f151cd633d35f8561341214c8c4a3828c6dbad170e846c605"},
{file = "floret-0.10.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a8486d383a077f4b41f78293d29a81afeee0f7fc4865b8cf39b218ff2135afa9"},
{file = "floret-0.10.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:101620e4b94e671b45b7c1e7c3c532cf45b3e37561c8e3b656d451c13e0a6f3a"},
{file = "floret-0.10.5-cp38-cp38-win_amd64.whl", hash = "sha256:217dc18c3cbd2491c2c49fc7cfb9b55eb94af19930bbef65f24037e28af59ea8"},
{file = "floret-0.10.5-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:620bc8218a8586f56f2ddcc9e21657cdefa03c255d9e85a0f0cd2346ef1acc56"},
{file = "floret-0.10.5-cp39-cp39-macosx_11_0_x86_64.whl", hash = "sha256:c24db59a80883e15361c3c23c16f9f50bb5df47cec5a5253510e1cff97e49970"},
{file = "floret-0.10.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7d8efe2add424b711ff6021f670498e9e0298dd92131553e52570558ec8b4c7c"},
{file = "floret-0.10.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3e1920a658a709f1366d0536d0e848b1bfb1370d16126480dc670ddd52626773"},
{file = "floret-0.10.5-cp39-cp39-win_amd64.whl", hash = "sha256:1f777dddfb4c2de9eec60bda92a1c4d4aea811a4d566ffe28ec4f56dacaaf139"},
{file = "floret-0.10.5.tar.gz", hash = "sha256:8a94654a87b3335499cd4d14532a6f947a8cc14bd3e28044d7ccf06e99084156"},
]
[package.dependencies]
numpy = "*"
[[package]] [[package]]
name = "freezegun" name = "freezegun"
version = "1.5.1" version = "1.5.1"
@ -1031,17 +1078,18 @@ files = [
[[package]] [[package]]
name = "ingredient-parser-nlp" name = "ingredient-parser-nlp"
version = "1.3.2" version = "2.0.0"
description = "A Python package to parse structured information from recipe ingredient sentences" description = "A Python package to parse structured information from recipe ingredient sentences"
optional = false optional = false
python-versions = "<3.14,>=3.10" python-versions = "<3.14,>=3.10"
groups = ["main"] groups = ["main"]
files = [ files = [
{file = "ingredient_parser_nlp-1.3.2-py3-none-any.whl", hash = "sha256:4e9b18a977e6b93985edd5a2668e5bb4f1dd3c570374316fb7f811a21ca55523"}, {file = "ingredient_parser_nlp-2.0.0-py3-none-any.whl", hash = "sha256:d027d2bb2648b9ec512582bd18cc9374aacef47dc2736b350061f34fba99d80f"},
{file = "ingredient_parser_nlp-1.3.2.tar.gz", hash = "sha256:12f4d34717364881b828b476bd5b5f8a72c96474883b8cbe94911a39fd71e719"}, {file = "ingredient_parser_nlp-2.0.0.tar.gz", hash = "sha256:f1dfe810e89e6c9522b2052902359f92030d5f078b7da9f09dea67044b447f3f"},
] ]
[package.dependencies] [package.dependencies]
floret = "*"
nltk = ">=3.9.1" nltk = ">=3.9.1"
pint = ">=0.24.4" pint = ">=0.24.4"
python-crfsuite = "*" python-crfsuite = "*"
@ -1751,6 +1799,71 @@ files = [
[package.dependencies] [package.dependencies]
setuptools = "*" setuptools = "*"
[[package]]
name = "numpy"
version = "2.2.3"
description = "Fundamental package for array computing in Python"
optional = false
python-versions = ">=3.10"
groups = ["main"]
files = [
{file = "numpy-2.2.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:cbc6472e01952d3d1b2772b720428f8b90e2deea8344e854df22b0618e9cce71"},
{file = "numpy-2.2.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:cdfe0c22692a30cd830c0755746473ae66c4a8f2e7bd508b35fb3b6a0813d787"},
{file = "numpy-2.2.3-cp310-cp310-macosx_14_0_arm64.whl", hash = "sha256:e37242f5324ffd9f7ba5acf96d774f9276aa62a966c0bad8dae692deebec7716"},
{file = "numpy-2.2.3-cp310-cp310-macosx_14_0_x86_64.whl", hash = "sha256:95172a21038c9b423e68be78fd0be6e1b97674cde269b76fe269a5dfa6fadf0b"},
{file = "numpy-2.2.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d5b47c440210c5d1d67e1cf434124e0b5c395eee1f5806fdd89b553ed1acd0a3"},
{file = "numpy-2.2.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0391ea3622f5c51a2e29708877d56e3d276827ac5447d7f45e9bc4ade8923c52"},
{file = "numpy-2.2.3-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:f6b3dfc7661f8842babd8ea07e9897fe3d9b69a1d7e5fbb743e4160f9387833b"},
{file = "numpy-2.2.3-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:1ad78ce7f18ce4e7df1b2ea4019b5817a2f6a8a16e34ff2775f646adce0a5027"},
{file = "numpy-2.2.3-cp310-cp310-win32.whl", hash = "sha256:5ebeb7ef54a7be11044c33a17b2624abe4307a75893c001a4800857956b41094"},
{file = "numpy-2.2.3-cp310-cp310-win_amd64.whl", hash = "sha256:596140185c7fa113563c67c2e894eabe0daea18cf8e33851738c19f70ce86aeb"},
{file = "numpy-2.2.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:16372619ee728ed67a2a606a614f56d3eabc5b86f8b615c79d01957062826ca8"},
{file = "numpy-2.2.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:5521a06a3148686d9269c53b09f7d399a5725c47bbb5b35747e1cb76326b714b"},
{file = "numpy-2.2.3-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:7c8dde0ca2f77828815fd1aedfdf52e59071a5bae30dac3b4da2a335c672149a"},
{file = "numpy-2.2.3-cp311-cp311-macosx_14_0_x86_64.whl", hash = "sha256:77974aba6c1bc26e3c205c2214f0d5b4305bdc719268b93e768ddb17e3fdd636"},
{file = "numpy-2.2.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d42f9c36d06440e34226e8bd65ff065ca0963aeecada587b937011efa02cdc9d"},
{file = "numpy-2.2.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f2712c5179f40af9ddc8f6727f2bd910ea0eb50206daea75f58ddd9fa3f715bb"},
{file = "numpy-2.2.3-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:c8b0451d2ec95010d1db8ca733afc41f659f425b7f608af569711097fd6014e2"},
{file = "numpy-2.2.3-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:d9b4a8148c57ecac25a16b0e11798cbe88edf5237b0df99973687dd866f05e1b"},
{file = "numpy-2.2.3-cp311-cp311-win32.whl", hash = "sha256:1f45315b2dc58d8a3e7754fe4e38b6fce132dab284a92851e41b2b344f6441c5"},
{file = "numpy-2.2.3-cp311-cp311-win_amd64.whl", hash = "sha256:9f48ba6f6c13e5e49f3d3efb1b51c8193215c42ac82610a04624906a9270be6f"},
{file = "numpy-2.2.3-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:12c045f43b1d2915eca6b880a7f4a256f59d62df4f044788c8ba67709412128d"},
{file = "numpy-2.2.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:87eed225fd415bbae787f93a457af7f5990b92a334e346f72070bf569b9c9c95"},
{file = "numpy-2.2.3-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:712a64103d97c404e87d4d7c47fb0c7ff9acccc625ca2002848e0d53288b90ea"},
{file = "numpy-2.2.3-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:a5ae282abe60a2db0fd407072aff4599c279bcd6e9a2475500fc35b00a57c532"},
{file = "numpy-2.2.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5266de33d4c3420973cf9ae3b98b54a2a6d53a559310e3236c4b2b06b9c07d4e"},
{file = "numpy-2.2.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3b787adbf04b0db1967798dba8da1af07e387908ed1553a0d6e74c084d1ceafe"},
{file = "numpy-2.2.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:34c1b7e83f94f3b564b35f480f5652a47007dd91f7c839f404d03279cc8dd021"},
{file = "numpy-2.2.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:4d8335b5f1b6e2bce120d55fb17064b0262ff29b459e8493d1785c18ae2553b8"},
{file = "numpy-2.2.3-cp312-cp312-win32.whl", hash = "sha256:4d9828d25fb246bedd31e04c9e75714a4087211ac348cb39c8c5f99dbb6683fe"},
{file = "numpy-2.2.3-cp312-cp312-win_amd64.whl", hash = "sha256:83807d445817326b4bcdaaaf8e8e9f1753da04341eceec705c001ff342002e5d"},
{file = "numpy-2.2.3-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:7bfdb06b395385ea9b91bf55c1adf1b297c9fdb531552845ff1d3ea6e40d5aba"},
{file = "numpy-2.2.3-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:23c9f4edbf4c065fddb10a4f6e8b6a244342d95966a48820c614891e5059bb50"},
{file = "numpy-2.2.3-cp313-cp313-macosx_14_0_arm64.whl", hash = "sha256:a0c03b6be48aaf92525cccf393265e02773be8fd9551a2f9adbe7db1fa2b60f1"},
{file = "numpy-2.2.3-cp313-cp313-macosx_14_0_x86_64.whl", hash = "sha256:2376e317111daa0a6739e50f7ee2a6353f768489102308b0d98fcf4a04f7f3b5"},
{file = "numpy-2.2.3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8fb62fe3d206d72fe1cfe31c4a1106ad2b136fcc1606093aeab314f02930fdf2"},
{file = "numpy-2.2.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:52659ad2534427dffcc36aac76bebdd02b67e3b7a619ac67543bc9bfe6b7cdb1"},
{file = "numpy-2.2.3-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:1b416af7d0ed3271cad0f0a0d0bee0911ed7eba23e66f8424d9f3dfcdcae1304"},
{file = "numpy-2.2.3-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:1402da8e0f435991983d0a9708b779f95a8c98c6b18a171b9f1be09005e64d9d"},
{file = "numpy-2.2.3-cp313-cp313-win32.whl", hash = "sha256:136553f123ee2951bfcfbc264acd34a2fc2f29d7cdf610ce7daf672b6fbaa693"},
{file = "numpy-2.2.3-cp313-cp313-win_amd64.whl", hash = "sha256:5b732c8beef1d7bc2d9e476dbba20aaff6167bf205ad9aa8d30913859e82884b"},
{file = "numpy-2.2.3-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:435e7a933b9fda8126130b046975a968cc2d833b505475e588339e09f7672890"},
{file = "numpy-2.2.3-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:7678556eeb0152cbd1522b684dcd215250885993dd00adb93679ec3c0e6e091c"},
{file = "numpy-2.2.3-cp313-cp313t-macosx_14_0_arm64.whl", hash = "sha256:2e8da03bd561504d9b20e7a12340870dfc206c64ea59b4cfee9fceb95070ee94"},
{file = "numpy-2.2.3-cp313-cp313t-macosx_14_0_x86_64.whl", hash = "sha256:c9aa4496fd0e17e3843399f533d62857cef5900facf93e735ef65aa4bbc90ef0"},
{file = "numpy-2.2.3-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f4ca91d61a4bf61b0f2228f24bbfa6a9facd5f8af03759fe2a655c50ae2c6610"},
{file = "numpy-2.2.3-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:deaa09cd492e24fd9b15296844c0ad1b3c976da7907e1c1ed3a0ad21dded6f76"},
{file = "numpy-2.2.3-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:246535e2f7496b7ac85deffe932896a3577be7af8fb7eebe7146444680297e9a"},
{file = "numpy-2.2.3-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:daf43a3d1ea699402c5a850e5313680ac355b4adc9770cd5cfc2940e7861f1bf"},
{file = "numpy-2.2.3-cp313-cp313t-win32.whl", hash = "sha256:cf802eef1f0134afb81fef94020351be4fe1d6681aadf9c5e862af6602af64ef"},
{file = "numpy-2.2.3-cp313-cp313t-win_amd64.whl", hash = "sha256:aee2512827ceb6d7f517c8b85aa5d3923afe8fc7a57d028cffcd522f1c6fd082"},
{file = "numpy-2.2.3-pp310-pypy310_pp73-macosx_10_15_x86_64.whl", hash = "sha256:3c2ec8a0f51d60f1e9c0c5ab116b7fc104b165ada3f6c58abf881cb2eb16044d"},
{file = "numpy-2.2.3-pp310-pypy310_pp73-macosx_14_0_x86_64.whl", hash = "sha256:ed2cf9ed4e8ebc3b754d398cba12f24359f018b416c380f577bbae112ca52fc9"},
{file = "numpy-2.2.3-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:39261798d208c3095ae4f7bc8eaeb3481ea8c6e03dc48028057d3cbdbdb8937e"},
{file = "numpy-2.2.3-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:783145835458e60fa97afac25d511d00a1eca94d4a8f3ace9fe2043003c678e4"},
{file = "numpy-2.2.3.tar.gz", hash = "sha256:dbdc15f0c81611925f382dfa97b3bd0bc2c1ce19d4fe50482cb0ddc12ba30020"},
]
[[package]] [[package]]
name = "oauthlib" name = "oauthlib"
version = "3.2.2" version = "3.2.2"
@ -3769,4 +3882,4 @@ pgsql = ["psycopg2-binary"]
[metadata] [metadata]
lock-version = "2.1" lock-version = "2.1"
python-versions = ">=3.12,<3.13" python-versions = ">=3.12,<3.13"
content-hash = "9a19a1b0f75cce3df8c69bcb8b41da14f12fc127e0d26e1a8fb0de2776666448" content-hash = "8dbeaaa25b196433ef250820ab9aec4306968827a0e6e06e70da1aa08bf5779d"

View file

@ -54,7 +54,7 @@ pyjwt = "^2.8.0"
openai = "^1.63.0" openai = "^1.63.0"
typing-extensions = "^4.12.2" typing-extensions = "^4.12.2"
itsdangerous = "^2.2.0" itsdangerous = "^2.2.0"
ingredient-parser-nlp = "^1.3.2" ingredient-parser-nlp = "^2.0.0"
[tool.poetry.group.postgres.dependencies] [tool.poetry.group.postgres.dependencies]
psycopg2-binary = { version = "^2.9.1" } psycopg2-binary = { version = "^2.9.1" }

View file

@ -8,7 +8,7 @@ from tests.utils.fixture_schemas import TestUser
nlp_test_ingredients = [ nlp_test_ingredients = [
TestIngredient("½ cup all-purpose flour", 0.5, "cup", "all-purpose flour", ""), TestIngredient("½ cup all-purpose flour", 0.5, "cup", "all-purpose flour", ""),
TestIngredient("1½ teaspoons ground black pepper", 1.5, "teaspoon", "ground black pepper", ""), TestIngredient("1½ teaspoons ground black pepper", 1.5, "teaspoon", "black pepper", "ground"),
TestIngredient("⅔ cup unsweetened flaked coconut", 0.667, "cup", "unsweetened flaked coconut", ""), TestIngredient("⅔ cup unsweetened flaked coconut", 0.667, "cup", "unsweetened flaked coconut", ""),
TestIngredient("⅓ cup panko bread crumbs", 0.333, "cup", "panko bread crumbs", ""), TestIngredient("⅓ cup panko bread crumbs", 0.333, "cup", "panko bread crumbs", ""),
TestIngredient("1/8 cup all-purpose flour", 0.125, "cup", "all-purpose flour", ""), TestIngredient("1/8 cup all-purpose flour", 0.125, "cup", "all-purpose flour", ""),
@ -23,14 +23,21 @@ nlp_test_ingredients = [
), ),
TestIngredient("2 tablespoons (30ml) vegetable oil ", 2, "tablespoon", "vegetable oil", ""), TestIngredient("2 tablespoons (30ml) vegetable oil ", 2, "tablespoon", "vegetable oil", ""),
TestIngredient("2 teaspoons salt (to taste) ", 2, "teaspoon", "salt", "to taste"), TestIngredient("2 teaspoons salt (to taste) ", 2, "teaspoon", "salt", "to taste"),
TestIngredient("2 cups chicken broth or beef broth ", 2, "cup", "chicken broth", ""),
TestIngredient("1/2 cup", 0.5, "cup", "", ""),
] ]
def assert_ingredient(api_response: dict, test_ingredient: TestIngredient): def assert_ingredient(api_response: dict, test_ingredient: TestIngredient):
assert api_response["ingredient"]["quantity"] == pytest.approx(test_ingredient.quantity) response_quantity = api_response["ingredient"]["quantity"]
assert api_response["ingredient"]["unit"]["name"] == test_ingredient.unit response_unit = api_response["ingredient"]["unit"]["name"] if api_response["ingredient"]["unit"] else ""
assert api_response["ingredient"]["food"]["name"] == test_ingredient.food response_food = api_response["ingredient"]["food"]["name"] if api_response["ingredient"]["food"] else ""
assert api_response["ingredient"]["note"] == test_ingredient.comments response_note = api_response["ingredient"]["note"]
assert response_quantity == pytest.approx(test_ingredient.quantity)
assert response_unit == test_ingredient.unit
assert response_food == test_ingredient.food
assert response_note == test_ingredient.comments
@pytest.mark.parametrize("test_ingredient", nlp_test_ingredients) @pytest.mark.parametrize("test_ingredient", nlp_test_ingredients)