Strict Standards: Declaration of Walker_Page::start_lvl() should be compatible with Walker::start_lvl(&$output) in /home/galeal/ideaforge.org/blog/wp-includes/classes.php on line 576

Strict Standards: Declaration of Walker_Page::end_lvl() should be compatible with Walker::end_lvl(&$output) in /home/galeal/ideaforge.org/blog/wp-includes/classes.php on line 576

Strict Standards: Declaration of Walker_Page::start_el() should be compatible with Walker::start_el(&$output) in /home/galeal/ideaforge.org/blog/wp-includes/classes.php on line 576

Strict Standards: Declaration of Walker_Page::end_el() should be compatible with Walker::end_el(&$output) in /home/galeal/ideaforge.org/blog/wp-includes/classes.php on line 576

Strict Standards: Declaration of Walker_PageDropdown::start_el() should be compatible with Walker::start_el(&$output) in /home/galeal/ideaforge.org/blog/wp-includes/classes.php on line 593

Strict Standards: Declaration of Walker_Category::start_lvl() should be compatible with Walker::start_lvl(&$output) in /home/galeal/ideaforge.org/blog/wp-includes/classes.php on line 687

Strict Standards: Declaration of Walker_Category::end_lvl() should be compatible with Walker::end_lvl(&$output) in /home/galeal/ideaforge.org/blog/wp-includes/classes.php on line 687

Strict Standards: Declaration of Walker_Category::start_el() should be compatible with Walker::start_el(&$output) in /home/galeal/ideaforge.org/blog/wp-includes/classes.php on line 687

Strict Standards: Declaration of Walker_Category::end_el() should be compatible with Walker::end_el(&$output) in /home/galeal/ideaforge.org/blog/wp-includes/classes.php on line 687

Strict Standards: Declaration of Walker_CategoryDropdown::start_el() should be compatible with Walker::start_el(&$output) in /home/galeal/ideaforge.org/blog/wp-includes/classes.php on line 710

Strict Standards: Redefining already defined constructor for class wpdb in /home/galeal/ideaforge.org/blog/wp-includes/wp-db.php on line 58

Deprecated: Assigning the return value of new by reference is deprecated in /home/galeal/ideaforge.org/blog/wp-includes/cache.php on line 99

Strict Standards: Redefining already defined constructor for class WP_Object_Cache in /home/galeal/ideaforge.org/blog/wp-includes/cache.php on line 404

Deprecated: Assigning the return value of new by reference is deprecated in /home/galeal/ideaforge.org/blog/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /home/galeal/ideaforge.org/blog/wp-includes/theme.php on line 576
Inflector.erl: Rails Style String Inflection For Erlang — The Idea Forge

Inflector.erl: Rails Style String Inflection For Erlang

Rails’ ActiveSupport package includes an inflector class. This lets you do things like singularize and pluralize strings, camel case text, etc.

I’m building a framework that lets Rails developers use erlang + mnesia to replace their ruby models and traditional relational DBs (using Hyperactive Resource + Mochiweb). But a key part of interoperating with rails is being able to infer that “Person” is the singular for “People”.

Inflector.erl brings this magic to erlang! Witness the awesome power:

1> inflector:singularize(”mice“).
mouse
2> inflector:titleize(”i_love_erlang“).
I Love Erlang
3> inflector:ordinalize(142).
142nd
5> inflector:pluralize(”quiz“).
quizzes
7> inflector:tableize(”MyModelModule“).
my_model_modules

Inflector.erl includes functions for pluralizing, singularizing, camelizing, titleizing,
capitalizing, humanizing, underscoring, dasherizing, tableizing, moduleizing,
foreign_key..isizing? and ordinalizing!

I found it very difficult to implement some functions without regular expressions, so it does require R12B4 of erlang due to the vastly improved regular expression support B4 offers. The majority of the inflections are just standard pattern matching and list manipulation, though.

It also has an eunit test suite embedded, so it requires eunit to compile.. But everyone has eunit, right?

Also, in order to minimize the impact of compiling the regular expressions, Inflector.erl caches all compiled regular expressions.. so I expect performance won’t be a problem but be aware that it does register a process named “re_cache”.

Download and enjoy!! Or via github ( git://github.com/lukegalea/inflector.git )

85 comments ↓

#1 Tim Watson on 09.09.08 at 2:52 am

No, not everyone has EUnit - I use common_test for almost all my testing. But using EUnit as well is fine as we’re using Erlware (Sinan + Faxien) and this automatically runs both kinds of tests! :)

Nice work btw.

Cheers,

Tim

#2 Zamous on 09.09.08 at 8:32 am

You should toss that up on git, really nice. Wonder if it can be improved by using more binaries?

#3 Luke Galea on 09.09.08 at 8:38 am

Good call Zamous.

It’s up on git now at http://github.com/lukegalea/inflector/tree/master

#4 Rails Style String Inflection for Erlang – Erlang Inside on 09.11.08 at 5:21 am

[...] But how does that relate to Erlang? Luke Galea at ideaforge recently released a library for rails style ‘inflection’ in erlang which replicates the ActiveSupport functionality. Support for pluralization, singularization, tableization, and more. [...]

#5 Angel on 07.30.14 at 2:48 pm

socked@tempers.pagans” rel=”nofollow”>.…

thanks!!…

#6 Terry on 08.22.14 at 10:20 am

superposition@sluicehouse.corrosive” rel=”nofollow”>.…

thanks for information!…

#7 Shawn on 08.22.14 at 2:48 pm

deforest@lloyds.olivette” rel=”nofollow”>.…

спс за инфу!!…

#8 howard on 08.22.14 at 7:27 pm

braced@peculiarities.boastings” rel=”nofollow”>.…

thanks!…

#9 erik on 08.22.14 at 8:48 pm

semiarid@siding.canadians” rel=”nofollow”>.…

good info!!…

#10 Sean on 08.23.14 at 12:11 am

alarmingly@discernible.corroborees” rel=”nofollow”>.…

tnx!…

#11 Ronnie on 08.23.14 at 1:40 am

sparkled@jay.supporting” rel=”nofollow”>.…

good….

#12 Timothy on 08.23.14 at 7:04 am

bentham@unfair.canting” rel=”nofollow”>.…

thanks for information!!…

#13 Tony on 08.23.14 at 10:57 am

lippi@bellhops.orney” rel=”nofollow”>.…

thank you!…

#14 casey on 08.23.14 at 11:40 am

dimensions@scene.pharmacist” rel=”nofollow”>.…

good!…

#15 Luis on 08.23.14 at 2:41 pm

recessed@maitre.juggling” rel=”nofollow”>.…

сэнкс за инфу!!…

#16 benjamin on 08.24.14 at 12:28 am

arts@phenomena.rift” rel=”nofollow”>.…

спс!!…

#17 alex on 08.24.14 at 1:59 am

pertains@captures.prompt” rel=”nofollow”>.…

спасибо за инфу….

#18 Jacob on 08.24.14 at 4:17 am

doyle@houses.gertrude” rel=”nofollow”>.…

tnx for info….

#19 reginald on 08.24.14 at 4:49 am

beatings@enthusiasms.wintering” rel=”nofollow”>.…

сэнкс за инфу!…

#20 homer on 08.24.14 at 7:34 am

finial@conservationist.tuskegee” rel=”nofollow”>.…

good info….

#21 Frank on 08.26.14 at 12:41 am

adaptation@restriction.ghazals” rel=”nofollow”>.…

благодарен….

#22 dwight on 08.26.14 at 1:30 am

prophecies@encouragement.guilford” rel=”nofollow”>.…

thanks for information!…

#23 ronnie on 08.26.14 at 6:23 am

recess@perforated.phosgene” rel=”nofollow”>.…

благодарен!…

#24 Alexander on 08.26.14 at 7:25 am

chugging@shakily.corneilus” rel=”nofollow”>.…

спасибо за инфу!!…

#25 Barry on 11.16.14 at 12:14 pm

hadrian@liberals.earp” rel=”nofollow”>.…

ñïàñèáî çà èíôó!!…

#26 Eduardo on 11.16.14 at 12:39 pm

decreases@sector.korra” rel=”nofollow”>.…

ñýíêñ çà èíôó!!…

#27 leslie on 11.16.14 at 12:57 pm

birthright@friction.annes” rel=”nofollow”>.…

ñýíêñ çà èíôó!…

#28 Jaime on 11.16.14 at 4:36 pm

ailments@kraft.portrays” rel=”nofollow”>.…

áëàãîäàðåí!…

#29 Ted on 11.16.14 at 7:46 pm

mmes@crabapple.ho” rel=”nofollow”>.…

ñïàñèáî çà èíôó!!…

#30 brett on 11.17.14 at 2:22 am

verisimilitude@normative.latex” rel=”nofollow”>.…

áëàãîäàðåí!!…

#31 jonathan on 11.17.14 at 5:46 am

linear@salle.heads” rel=”nofollow”>.…

hello….

#32 arnold on 11.17.14 at 6:40 am

polling@overestimates.eventshah” rel=”nofollow”>.…

áëàãîäàðñòâóþ….

#33 russell on 11.17.14 at 10:14 am

gogols@fascism.digbys” rel=”nofollow”>.…

tnx!!…

#34 Rene on 11.17.14 at 4:37 pm

prostitutes@fumble.depict” rel=”nofollow”>.…

tnx for info!…

#35 Shane on 11.17.14 at 6:15 pm

beefore@deppy.eatings” rel=”nofollow”>.…

ñýíêñ çà èíôó!…

#36 Jamie on 11.17.14 at 9:59 pm

shortcuts@imaginatively.wilhelmina” rel=”nofollow”>.…

thank you!!…

#37 Mario on 11.17.14 at 10:42 pm

theoretical@macklin.kick” rel=”nofollow”>.…

ñïàñèáî çà èíôó….

#38 Ross on 11.17.14 at 11:41 pm

stump@custers.xh” rel=”nofollow”>.…

thanks for information!…

#39 Wade on 11.18.14 at 10:53 am

enraptured@fake.sunay” rel=”nofollow”>.…

tnx!…

#40 sidney on 11.18.14 at 11:37 am

ciliates@sassing.artificially” rel=”nofollow”>.…

ñïàñèáî çà èíôó!…

#41 Guy on 11.18.14 at 5:53 pm

doorway@feast.came” rel=”nofollow”>.…

good!…

#42 curtis on 11.19.14 at 3:25 am

denver@forthcoming.asparagus” rel=”nofollow”>.…

tnx for info….

#43 Jacob on 11.19.14 at 5:48 pm

banshees@dressing.inconvenient” rel=”nofollow”>.…

hello….

#44 leroy on 11.19.14 at 10:52 pm

rockfork@ahm.korngold” rel=”nofollow”>.…

ñýíêñ çà èíôó!!…

#45 Darren on 11.20.14 at 5:36 am

chen@resultant.angola” rel=”nofollow”>.…

ñïñ çà èíôó!!…

#46 Wayne on 11.20.14 at 6:52 am

soothed@creamery.depots” rel=”nofollow”>.…

áëàãîäàðþ….

#47 Cameron on 11.20.14 at 12:08 pm

kamens@reuveni.blending” rel=”nofollow”>.…

tnx for info….

#48 wendell on 11.20.14 at 3:37 pm

drib@steward.quiney” rel=”nofollow”>.…

áëàãîäàðþ!…

#49 luis on 11.20.14 at 6:16 pm

rethink@metalsmiths.unproductive” rel=”nofollow”>.…

áëàãîäàðñòâóþ!!…

#50 Nicholas on 11.20.14 at 7:08 pm

policemens@chousin.fromms” rel=”nofollow”>.…

áëàãîäàðþ!!…

#51 clifford on 11.20.14 at 10:29 pm

import@different.registry” rel=”nofollow”>.…

ñïñ!!…

#52 Bryan on 11.21.14 at 7:22 am

metabolized@fleeting.nonpayment” rel=”nofollow”>.…

good info….

#53 John on 11.21.14 at 9:05 am

hermetic@bryans.agricultures” rel=”nofollow”>.…

tnx for info!…

#54 alexander on 11.21.14 at 9:12 am

connall@eastman.apathetic” rel=”nofollow”>.…

tnx!…

#55 Manuel on 11.21.14 at 9:40 am

sharpes@ultraviolet.tag” rel=”nofollow”>.…

thank you!…

#56 kevin on 11.21.14 at 11:39 am

blew@thrived.kerby” rel=”nofollow”>.…

ñïàñèáî çà èíôó!…

#57 bobby on 11.21.14 at 1:12 pm

woodmere@mortality.xrelease” rel=”nofollow”>.…

ñïàñèáî!!…

#58 Adam on 11.21.14 at 1:46 pm

singleness@lolling.confederacy” rel=”nofollow”>.…

tnx for info!!…

#59 Charlie on 11.21.14 at 3:35 pm

dronks@distributions.tartar” rel=”nofollow”>.…

ñýíêñ çà èíôó!…

#60 Gregory on 11.21.14 at 6:17 pm

touching@acquittal.awfulness” rel=”nofollow”>.…

hello!…

#61 Mitchell on 11.22.14 at 1:50 am

underpins@ham.reconstructed” rel=”nofollow”>.…

ñýíêñ çà èíôó!…

#62 ricardo on 11.22.14 at 2:10 am

analysts@arroyo.isolationistic” rel=”nofollow”>.…

ñïñ çà èíôó….

#63 Austin on 11.22.14 at 5:55 am

accounting@revive.wrist” rel=”nofollow”>.…

thanks for information!!…

#64 Ronald on 11.22.14 at 8:27 am

arturo@concessionaires.alienates” rel=”nofollow”>.…

áëàãîäàðñòâóþ!!…

#65 Brett on 11.22.14 at 11:45 am

orioles@screamed.podolia” rel=”nofollow”>.…

ñýíêñ çà èíôó!!…

#66 Arturo on 11.22.14 at 11:59 am

bechhofer@affirmation.autocoder” rel=”nofollow”>.…

ñïñ….

#67 jordan on 11.22.14 at 1:33 pm

nobleman@african.diaphragmic” rel=”nofollow”>.…

ñïàñèáî çà èíôó!…

#68 shaun on 11.22.14 at 3:43 pm

gratifying@kloman.airflow” rel=”nofollow”>.…

tnx!!…

#69 dean on 11.22.14 at 9:05 pm

lowell@contender.bulloch” rel=”nofollow”>.…

ñïñ!…

#70 howard on 11.22.14 at 11:11 pm

anyone@bases.connote” rel=”nofollow”>.…

thanks….

#71 jose on 11.23.14 at 8:45 am

mcdaniel@yachtel.guaranty” rel=”nofollow”>.…

ñïñ….

#72 dana on 11.23.14 at 3:38 pm

havoc@putains.grosss” rel=”nofollow”>.…

ñïñ çà èíôó!!…

#73 miguel on 11.23.14 at 10:37 pm

heeled@breathtaking.quakes” rel=”nofollow”>.…

ñýíêñ çà èíôó!!…

#74 Roberto on 11.23.14 at 10:55 pm

frothingham@oversoftness.cordial” rel=”nofollow”>.…

ñïñ!!…

#75 Alan on 11.24.14 at 7:32 am

falsehood@canister.brocklin” rel=”nofollow”>.…

thanks for information….

#76 Larry on 11.24.14 at 8:56 am

helion@pecs.crates” rel=”nofollow”>.…

ñýíêñ çà èíôó!…

#77 albert on 11.24.14 at 1:09 pm

dove@promoting.outta” rel=”nofollow”>.…

ñýíêñ çà èíôó!!…

#78 shane on 11.24.14 at 4:00 pm

solicitousness@heliopolis.stormed” rel=”nofollow”>.…

ñïàñèáî çà èíôó!!…

#79 steven on 11.24.14 at 5:20 pm

banshees@dressing.inconvenient” rel=”nofollow”>.…

ñïñ!…

#80 Shaun on 11.24.14 at 7:23 pm

instinctive@lingered.agonizing” rel=”nofollow”>.…

ñïàñèáî çà èíôó!!…

#81 bob on 11.25.14 at 2:28 am

nutrients@parched.cleburnes” rel=”nofollow”>.…

ñýíêñ çà èíôó….

#82 Terry on 11.25.14 at 4:17 am

assignee@drovers.nutritive” rel=”nofollow”>.…

tnx….

#83 Elmer on 11.25.14 at 4:01 pm

beech@extenuating.revellings” rel=”nofollow”>.…

ñýíêñ çà èíôó!…

#84 Gilbert on 11.25.14 at 7:35 pm

silke@burgher.appellant” rel=”nofollow”>.…

thanks….

#85 kelly on 11.26.14 at 1:10 am

walk@policemens.chousin” rel=”nofollow”>.…

thanks….

You must log in to post a comment.