Skip to content
Herbalist is a natural language measurements parser.
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
test
.document
.gitignore
Gemfile
Gemfile.lock
LICENSE
README.rdoc
Rakefile
herbalist.gemspec

README.rdoc

herbalist

Herbalist is a natural language measurements parser. It is built on top of the Alchemist gem and draws heavily from the Chronic.

Installation

$ sudo gem sources -a http://gemcutter.org
$ sudo gem install herbalist

Usage

>> require 'herbalist'
>> Herbalist.parse("a quarter cup")
=> #<Alchemist::NumericConversion @value=0.25, @exponent=1.0, @unit_name=:cup>

>> Herbalist.parse("it was two and a half football fields")
=> #<Alchemist::NumericConversion @value=2.5, @exponent=1.0, @unit_name=:football_fields>

>> Herbalist.parse('twenty-one and a half Miles')
=> #<Alchemist::NumericConversion @value=21.5, @exponent=1.0, @unit_name=:miles>

>> Herbalist.parse('fifteen kilowatt Hours')
=> #<Alchemist::NumericConversion @value=15.0, @exponent=1.0, @unit_name=:kilowatt_hours>

Limitations

Parsing is limited to units that Alchemist can understand.

TODO

-Allow parsing of units directly next to digits (ed 4m, 21.5L) -Add options to limit which type of units to parse (only volume or distance)

Copyright

Copyright © 2009 John Duff. See LICENSE for details.

Something went wrong with that request. Please try again.