Git Product home page Git Product logo

onigiri's Introduction

Onigiri - A Delicious Ingredient Parser.

Give onigiri an ingredient description from a recipe and it will parse the ingredeint name and the ammount used.

For example

result = Onigiri::Onigiri.parse('5 tablespoons of tomato sauce')
result.status       # :success
result.ammount      # 5.0
result.measurement  # 'tbsp'
result.ingredient   # 'tomato sauce'

or

result = Onigiri::Onigiri.parse('10 large chopped onions')
result.status         # :success
result.ammount        # 5.0
result.measurement    # 'tbsp'
result.modifier       # 'choppped'
result.ingredient     # 'tomato sauce'

it can also handle written ammounts such as a banana i.e. 1 banana or 1/2, 3/4 etc

Onigiri::Onigiri.parse('a frozen banana')
result.ammount # 1.0
result.modifier # 'frozen'
...

Onigiri::Onigiri.parse('1/2 diced pepper')
result.ammount # .5
result.modifier # 'diced'
...

If it can't parse a string for any reason resut.status will return :failed or :amibigous

:failed means epic fail and the string is propbably not an ingredient description at all

:ambiguous means the passed string could possibly be an ingredient description but it couldnt parse it (there were some matches but not enough to parse reliably)

result.text # holds the original string
result.normalized_text # returns a cleaned up version of the string (probably of no use)

I havently created a gem version of this but you can use bundler to install via

gem 'omusubi', :git => '....'

(there already is a gem called onigiri so i have called it omusubi in the gemspec (a synonym for onigiri) - this is a todo to fix ).

TODO

Lots

  • Onigiri::Onigiri is annoying, dont need Onigiri class.
  • remove definitions of ingredients, measurements etc to their own files.
  • and more!

onigiri's People

Contributors

adamakhtar avatar jmaziarz avatar

Watchers

 avatar James Cloos avatar

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.