Giter Club home page Giter Club logo

ingreedy's Introduction

Usage

result = Ingreedy.parse('1 lb. potatoes')
print result.amount
  #=> 1.0
print result.unit
  #=> :pound
print result.ingredient
  #=> "potatoes"

I18n and custom dictionaries

Ingreedy.dictionaries[:fr] = { 
  units: { dash: ['pincée'] }, 
  numbers: { 'une' => 1 }, 
  prepositions: ['de'] 
}

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

result = Ingreedy.parse('une pincée de sucre')
print result.amount
  #=> 1.0
print result.unit
  #=> :dash
print result.ingredient
  #=> "sucre"

Handling amounts

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

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

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

Ingreedy.preserve_amounts = true

result = Ingreedy.parse("1 1/2 cups flour")
print result.amount
  #=> 1 1/2

Live demo

Pieces of Flair

  • Gem Version
  • Build Status
  • Code Climate
  • Coverage Status

Development

Run the tests:

rspec spec

ingreedy's People

Contributors

andyw8 avatar balvig avatar djcp avatar dlackty avatar firewalker06 avatar herkyl avatar iancanderson avatar kabouzeid avatar mlarraz avatar tapster avatar timboisvert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ingreedy's Issues

empty string is causing NoMethodError rather than Ingreedy::ParseFailed

I would expect

require 'ingreedy'

Ingreedy.parse('')

to throw Ingreedy::ParseFailed rather than NoMethodError

/home/mateusz/.gem/ruby/2.3.0/gems/ingreedy-0.1.0/lib/ingreedy/unit_variation_mapper.rb:31:in `unit_from_variation': undefined method `first' for nil:NilClass (NoMethodError)
    from /home/mateusz/.gem/ruby/2.3.0/gems/ingreedy-0.1.0/lib/ingreedy/ingreedy_parser.rb:55:in `convert_unit_variation_to_canonical'
    from /home/mateusz/.gem/ruby/2.3.0/gems/ingreedy-0.1.0/lib/ingreedy/ingreedy_parser.rb:39:in `parse'
    from /home/mateusz/.gem/ruby/2.3.0/gems/ingreedy-0.1.0/lib/ingreedy.rb:16:in `parse'

Update on the status of this gem

@balvig @firewalker06 @tapster - Didn't know how else to reach you, but I wanted to say thanks for the work you've done on this gem, and apologize for not being more responsive to the PRs. @balvig - as of today I brought in the latest commits from your master branch into upstream master. FYI I rebased the changes on top of mine, so you might want to re-create your fork to make clear diffs for future PRs.

The latest gem version, 0.0.7 has the latest changes brought in from @balvig's fork.

I would like to better maintain the gem going forward, and would appreciate your help for future releases!

Dictionary missing from gem?

When I try to use the gem in a project, it fails with:

"2.2.0/gems/ingreedy-0.0.7/lib/ingreedy/dictionary_collection.rb:32:in `rescue in load_yaml': No dictionary found for :en locale (RuntimeError)"

I download the gem file and extracted it, and it does seem to be missing the lib/ingreedy/dictionaries directory, I guess it's because the gemspec is set to use Dir.glob("lib/**/*.rb") so misses the YAML.

should differentiate ingredients extra text... im talking about adding NLP

Its works great but also should remove extra texts.

ex: Ingredients list.

2 ounces thick-cut bacon (about 3 slices), small dice
1 medium yellow onion, small dice
3 cups fresh or frozen corn kernels (thaw if frozen)
3 cups whole milk
1 pound russet potatoes (about 2 medium), peeled and medium dice
2 teaspoons kosher salt, plus more as needed
1/2 teaspoon freshly ground black pepper, plus more as needed
1/2 cup heavy cream
Finely chopped chives, for serving

* This should give result like this

result.amount #=> 2
result.unit #=> :ounces
result.ingredient #=> "bacon "
result.text #=> thick-cut small dice

ex 2

result.amount #=> 1
result.unit #=> :medium
result.ingredient #=> " yellow onion"
result.text #=> small dice

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.