create Transpose Words automation
This commit is contained in:
@ -274,6 +274,10 @@ class IngredientParser:
|
|||||||
return: new ingredient string
|
return: new ingredient string
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
####################################################
|
||||||
|
####################################################
|
||||||
|
####################################################
|
||||||
|
####################################################
|
||||||
if self.ignore_rules:
|
if self.ignore_rules:
|
||||||
return ingredient
|
return ingredient
|
||||||
|
|
||||||
@ -309,6 +313,8 @@ class IngredientParser:
|
|||||||
if len(ingredient) == 0:
|
if len(ingredient) == 0:
|
||||||
raise ValueError('string to parse cannot be empty')
|
raise ValueError('string to parse cannot be empty')
|
||||||
|
|
||||||
|
ingredient = self.apply_transpose_words_automations(ingredient)
|
||||||
|
|
||||||
# some people/languages put amount and unit at the end of the ingredient string
|
# some people/languages put amount and unit at the end of the ingredient string
|
||||||
# if something like this is detected move it to the beginning so the parser can handle it
|
# if something like this is detected move it to the beginning so the parser can handle it
|
||||||
if len(ingredient) < 1000 and re.search(r'^([^\W\d_])+(.)*[1-9](\d)*\s*([^\W\d_])+', ingredient):
|
if len(ingredient) < 1000 and re.search(r'^([^\W\d_])+(.)*[1-9](\d)*\s*([^\W\d_])+', ingredient):
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Generated by Django 4.1.7 on 2023-04-24 15:00
|
# Generated by Django 4.1.7 on 2023-04-24 16:22
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user