Project

omnomnum

0.0
No commit activity in last 3 years
No release in over 3 years
OmNomNum normalizes numbers in ruby strings.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

OmNomNum

Wrapper for the OmNomNum c project, which implements most of the logic from numerizer.

Gem Version

Install

gem install omnomnum

Usage

require 'omnomnum'

OmNomNum.normalize('first')
=> "1st"
OmNomNum.normalize('second')
=> "second"
OmNomNum.normalize('second', parse_second: true)
=> "2nd"

Benchmarks

Memory

Library Bytes at exit Total # of Allocations Total Frees Total # of Bytes Allocated Savings
Numerizer1 2,746,272 59,243 35,161 11,055,638 -
Numerizer2 3,719,364 10,852,981 10,821,658 1,115,915,077 -
Numerizer3 973,092 10,793,738 10,786,497 1,104,859,439
OmNomNum1 2,657,613 57,967 34,681 10,797,999 -
OmNomNum2 2,659,473 62,006 38,700 10,839,010 -
OmNomNum3 1,860 4,039 4,019 41,011 25,000+×

1: loads the library and does nothing else
2: runs the string "two hundred" 2,000 times
3: difference between 1 and 2

Note: Benchmark done using valgrind. valgrind ruby -w Ilib test/memory_test_*.rb

CPU

Library Iterations per second Speedup
Numerizer 323.271
OmNomNum 2.516M 7,750+×

Notes

The OmNomNum actually has two methods: one that returns a normalized string, and one that returns a list containing the locations of the numbers in the string and their values. ruby_omnomnum currently only supports the first function, but the second could eventually be exposed.