Skip to content

jduff/herbalist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 © 2009 John Duff. See LICENSE for details.

About

Herbalist is a natural language measurements parser.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages