Giter Site home page Giter Site logo

ingredientparser's Introduction

Build Status

Ingredient Parser

Simple recipe ingredient parser. Parses a single line of text into a JavaScript Object that represents the best guess at what the ingredient line should be.

Works in any browser that supports Array.forEach, Array.reduce, and Object.keys.

Why?

I'm building a recipe management application and there were no good ingredient parsers in existence that worked in the browser. So, I wrote one.

Install

npm install ingredientparser

How

  1. Breaks up the input string on whitespace characters (space and tab)
  2. Checks for and concatenates numeric or fractional values
  3. Checks for optional or (optional)
  4. Checks for "to taste"
  5. Checks for text in ()'s to find preparation steps
  6. Removes all noise words
  7. Returns the resulting object

Input Schema

<amount> <unit> [of] (<prep>) <ingredient> optional|(optional) (<prep>)

Usage

var ing = require('ingredientparser');
console.log(ing.parse('1 cup brown sugar'));

Outputs:

{ amount: '1',
  unit: 'Cup',
  name: 'brown sugar' }

Tests

mocha test
or
npm test

Bug Reports

Found a bug, submit a new issue along with a failing test. If you feel really nice and want a thank you, submit a pull request to resolve it as well.

ingredientparser's People

Contributors

jdarling avatar

Watchers

 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.