cookpad/ingreedy

Name: ingreedy

Owner: Cookpad Inc.

Description: natural language parsing of recipe ingredients, making sense of amounts, units, and ingredients

Created: 2015-11-30 12:45:02.0

Updated: 2018-02-01 17:04:41.0

Pushed: 2017-11-01 10:32:29.0

Homepage:

Size: 113

Language: Ruby

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Usage

lt = Ingreedy.parse('1 lb. potatoes')
t result.amount
> 1.0
t result.unit
> :pound
t result.ingredient
> "potatoes"
I18n and custom dictionaries
eedy.dictionaries[:fr] = {
its: { dash: ['pincée'] },
mbers: { 'une' => 1 },
epositions: ['de']
nge_separators: ['ou']


eedy.locale = :fr # Also automatically follows I18n.locale if available

lt = Ingreedy.parse('une pincée de sucre')
t result.amount
> 1.0
t result.unit
> :dash
t result.ingredient
> "sucre"
Handling amounts

By default, Ingreedy will convert all amounts to a rational number:

lt = Ingreedy.parse("1 1/2 cups flour")
t result.amount
> 3/2

However, setting Ingreedy.preverse_amounts = true, will allow amounts to be detected and returned as originally input:

eedy.preserve_amounts = true

lt = Ingreedy.parse("1 1/2 cups flour")
t result.amount
> 1 1/2

Live demo

Pieces of Flair

Development

Run the tests:

c spec

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.