-
Notifications
You must be signed in to change notification settings - Fork 98
Handle fractions nicely during recalculations #2004
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
Comments
@j0hannesr0th do you think, you can extent the script in this direction? |
I've played a bit with fractions during the implementation and decided to parse fractions as decimal. I'll give you an example for a dessert pudding recipe:
Not sure if this feature is helpful for fractions... A possible solution I've thought about is:
|
For this reason, most recipes are also given for 1 or 4 portions and not for 7 (prime number) portions, as in the more theoretical example. In j0hannesr0th's example, the usual specification for 14 portions would not be 3/2 litres of milk but 1 1/2 litres of milk, Y you could use for example, if the quantity modulo 2 = 1, x 1/2. Similarly for 1/8, 1/4. Something similar would be possible for 1/3. Only if such a familiar representation is not possible should a decimal representation be used. Have a look on https://www.chefkoch.de/rezepte/845091189864506/Omas-Pizzasuppe.html?portionen=6 |
I checked the recipe you've provided but it works not properly (not with fractions) for 8 servings, too. It could have used 1/3 and 2/3 in some places, but has used the decimal version instead. The pudding problem I described is not a theoretical problem, it's a real life problem. I have some special dessert glasses and the original recipe was for 8 glasses. With my glasses it filled only 7 glasses - using 8 glasses made the glasses look empty. So instead of fixing all the ingredients I just changed the servings. Off topic for personal interest: @cloud2018 are you familiar with imperial measurement in cooking? I have a lot of ice recipes which often use 3 or 4 mg of locust bean gum. How do you show this in grain? 1/16 and 1/22 grains? It needs to be measured perfectly because if you use too much your ice cream will be like bubble gum and not creamy. |
I think the point of the request is the following. Lots of people are used to seeing We would still need to decide what happens to However, I would suggest to avoid overly complicated and unusal fractions (in recipes). Without having done any research it would say readable fractions are This would also mean |
@seyfeb as far as i remember "1/8 litres milk" is stored as varchar in the database. Talking about database standardisation you must then write a function which translates decimals to common "readable" fractions, since MariaDB can't store "native" fractions. How do you want to store "1 1/3 litres milk" in the database?
Like this? And how does the the user enter it?
I could provide more examples of why using fractions instead of decimals makes no sense, but since it's your project, I don't want to spend time discussing things that are ultimately unimportant and where I cannot make a decision. |
The question how to store these values in a structured way, as you asked is a good one. Currently this is no problem, since there are only strings stored in the JSON. Afaik they are not stored in the database, but it is discussed to store them in a more structured way, e.g., as a HowToSupply (see here). When storing Edit: You could obviously store every number in the database as nominator with denominator where floats have a denominator of 1. In the schema.org JSON the value can be a number or a string. |
I would like to add a plug for maintaining fractions in how ingredients are shown, especially if that’s how they were entered. I appreciate the app’s ability to calculate new ingredient quantities by changing the number of servings, but — at least for me — a lot of that quickly becomes meaningless… If a recipe for 4 servings is increased to 5 and I need to increase 1/4 tsp of something, I have no idea how to measure 0.31 tsp. Even if the app were to show the exact calculation of 0.3125 tsp, there’s not an intuitive conversion from that number to quantities supported by actual measuring spoons. But I can look at 1/4 tsp as my original quantity in the original recipe, pull out my 1/4 tsp spoon, use it for the base amount, and then estimate how to fill it 1/4 full to get enough ingredient for one more portion. As someone else said in this thread, I don’t want to tell you how to develop your app, which my entire family really appreciates. But I at least want to register a strong preference for fractions in ingredient lists when that was the original text — at least for the baseline number of servings. It’s the way home cooks have been conditioned to think. Maybe the solution could be to switch to decimals if someone changes the number of servings. If someone is doing that, they might be more understanding of the fact that the app needs to switch to decimals in order to calculate the new volumes and keep the coding manageable. |
Handle 16ths during recalculation of ingredients, else use decimal
Handle 16ths during recalculation of ingredients, else use decimal
Handle 16ths during recalculation of ingredients, else use decimal Signed-off-by: Christian Wolf <[email protected]>
Handle fractional ingredients (Fixes #2004)
Hi, the linked fix doesn't fully solve this issue because it notably omits support for 1/3s, which are fairly common in recipes here in the US. |
In recipes, fractions are usually used for the non-integer quantity, e.g. 1/2 tsp. The specification 0.5 tsp is rather uncommon.
It would be nice if the automatic change from the input (e.g. 1/3) to 0.33 could be prevented by configuration.
Ursprünglich gepostet von @cloud2018 in #1987 (comment)
The text was updated successfully, but these errors were encountered: