Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new string variants for a variety of units with tests. #18

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 68 additions & 1 deletion ingreedypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,10 @@ class Ingreedy(NodeVisitor):

cup
= "cups"
/ "cup(s)"
/ "cup"
/ "C."
/ "C"
/ "c."
/ "c"

Expand All @@ -203,7 +206,10 @@ class Ingreedy(NodeVisitor):
/ "fl"

gallon
= "gallons"
= "gallons."
/ "gallons"
/ "gallon(s)"
/ "gallon."
/ "gallon"
/ "gal."
/ "gal"
Expand All @@ -219,26 +225,35 @@ class Ingreedy(NodeVisitor):

ounce
= "ounces"
/ "ounce(s)"
/ "ounce."
/ "ounce"
/ "oz."
/ "oz"

pint
= "pints"
/ "pint(s)"
/ "pint."
/ "pint"
/ "pt."
/ "pt"

pound
= "pounds"
/ "pound(s)"
/ "pound."
/ "pound"
/ "lbs."
/ "lbs"
/ "lb."
/ "lb"
/ "#"

quart
= "quarts"
/ "quart(s)"
/ "quart."
/ "quart"
/ "qts."
/ "qts"
Expand All @@ -247,17 +262,32 @@ class Ingreedy(NodeVisitor):

tablespoon
= "tablespoons"
/ "tablespoon(s)"
/ "tablespoon."
/ "tablespoon"
/ "tbspns."
/ "tbspns"
/ "Tbsp."
/ "Tbsp"
/ "tbsp."
/ "tbsp"
/ "TBS."
/ "TBS"
/ "Tbs."
/ "Tbs"
/ "tbs."
/ "tbs"
/ "T."
/ "T"

teaspoon
= "teaspoons"
/ "teaspoon(s)"
/ "teaspoon"
/ "teasps."
/ "teasps"
/ "teasp."
/ "teasp"
/ "tsp."
/ "tsp"
/ "t."
Expand All @@ -274,44 +304,63 @@ class Ingreedy(NodeVisitor):

gram
= "grams"
/ "gram(s)"
/ "gram"
/ "gr."
/ "gr"
/ "G."
/ "G"
/ "g."
/ "g"

joule
= "joules"
/ "joule(s)"
/ "joule"
/ "j"

kilogram
= "kilograms"
/ "kilogram(s)"
/ "kilogram"
/ "KG."
/ "KG"
/ "Kg."
/ "Kg"
/ "kg."
/ "kg"

kilojoule
= "kilojoules"
/ "kilojoule(s)"
/ "kilojoule"
/ "kJ"
/ "kj"

liter
= "liters"
/ "liter(s)"
/ "liter"
/ "L."
/ "L"
/ "l."
/ "l"

milligram
= "milligrams"
/ "milligram(s)"
/ "milligram"
/ "mgs."
/ "mgs"
/ "mg."
/ "mg"

milliliter
= "milliliters"
/ "milliliter(s)"
/ "milliliter"
/ "mls."
/ "mls"
/ "ml."
/ "ml"

Expand All @@ -320,6 +369,13 @@ class Ingreedy(NodeVisitor):
/ handful
/ pinch
/ touch
/ stick
/ punnet
/ head

head
= "heads"
/ "head"

abbreviated_unit
= letter letter letter?
Expand All @@ -340,6 +396,17 @@ class Ingreedy(NodeVisitor):
= "touches"
/ "touch"

stick
= "sticks"
/ "stick(s)"
/ "stick"

punnet
= "punnetts"
/ "punnett"
/ "punnets"
/ "punnet"

number = written_number break

written_number
Expand Down
Loading