Skip to content

possible quanto basta solution - #5

Open
scolobey wants to merge 11 commits into
suprmat95:masterfrom
scolobey:quanto-basta
Open

possible quanto basta solution#5
scolobey wants to merge 11 commits into
suprmat95:masterfrom
scolobey:quanto-basta

Conversation

@scolobey

Copy link
Copy Markdown

Added the key baseUnits to LanguageConfig.
If there is no identified quantity or unit in parse, and there is a specified baseUnits that is > 0 characters in length, the unit is identified as baseUnit.

scolobey and others added 10 commits June 11, 2022 07:36
At least for English, the units list contains both caps and lowercase options. This becomes important because 't' designates teaspoon and 'T' designates Tablespoon.

In addition to accurately identifying these edge cases 't' and 'T', the matched text is returned and used as the 'originalUnit' later to remove the unit from the ingredient string. This was causing the following commented English test to fail.
"25 lb beef stew chunks (or buy a roast and chop into small cubes)"

Because 'lb' was matching for both 'lb' and 'Lb' in the units list, and 'Lb' comes second, the final match being returned was for 'Lb' so when the unit is later removed via a replace() it tries to remove 'Lb' and finds nothing, so the ingredient text ends up being 'lb beef stew chunks' instead of 'beef stew chunks'
Remove 'case insensitive' designator on singular unit match regex.
* Added Prettier
* Added missing dev dependencies
* Formatted all files
* Split out test files
* Fixed failing tests related to english language
* Fixed combination and prettyprint logic
* Added CI tests
* Removed unnecessary capitalised duplicates
* Removed logs
* Refactored nested ifs
* Corrected typescript error
* Removed prettier config lines
* Type fixes
* Accounted for words like "butter" when looking for "to taste" regex (i.e. "tt")
* Refactored into multiple language files
* Added German Language
* Updated README and removed duplicate locks
* Added support for multiple joiners and numbers like 1,200.30
* Added support for commas instead of periods for decimals
* Modified regex detector to allow for Umlaut characters that are word breaking
* Fixed unicode fractions
* Added "Bund" german term
* Corrected order of English items
* Fixes some German translations and adds KL
* Added linting workflow

Co-authored-by: Sebastian Weggesser <sebastian.weggesser@googlemail.com>
# Conflicts:
#	package-lock.json
#	src/index.ts
#	src/numbers.ts
#	src/units.ts
#	test/index.test.ts

@benjackwhite benjackwhite left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants