Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Herbalist is a natural language measurements parser.
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib Bump gem version
test Remove shoulda-context dev dependency
.document Initial commit to herbalist.
.gitignore Initial commit to herbalist.
Gemfile Uses newer version of alchemist library
Gemfile.lock
LICENSE updated the readme and rakefile with description and some documentation
README.rdoc updated the readme and rakefile with description and some documentation
Rakefile Uses newer version of alchemist library
herbalist.gemspec less strict dependencies

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.