possible quanto basta solution - #5
Open
scolobey wants to merge 11 commits into
Open
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.