Show HN: Parse recipe ingredients using JavaScript

README.md

Parses ingredient strings into units, amounts and ingredient names. Forked from the now dead Ingreedyjs project.

Installation

npm install ingredients-parser –save

Usage

var parser = require(‘ingredients-parser’);

var result = parser.parse(‘500ml milk’);
result.amount //=> ‘500’
result.unit //=> ‘ml’
result.ingredient //=> “milk”

result = parser.parse(‘two kg of all purpouse flour’);
result.amount //=> ‘two’
result.unit //=> ‘kg’
result.ingredient //=> “all purpouse flour”

Contributing

If you wish to change the parser you need to change rules.pegjs file. The pegjs-generated.js file is generated by PEG.js.

Building

make build

Testing

make test


Original URL: http://feedproxy.google.com/~r/feedsapi/BwPx/~3/lukVLSxdmPY/ingredients-parser

Original article

Comments are closed.

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑

%d bloggers like this: