Git Product home page Git Product logo

inflector's Introduction

Inflectorex

Build Status

Inflectorex pluralizes and singularizes English nouns.

Usage

Inflectorex.singularize("workers") # will give "worker"

Inflectorex.pluralize("secret") # will give "secrets"

Extending the regex lists

Currently the application has 4 regex lists. You can extend these lists using the config block. To extend each of the lists the keys are as follows -

  • @plural_regexps - plural
  • @singular_regexps - singular
  • @singular_uninflected - singular_uninflected
  • @plural_uninflected - plural_uninflected

Note - right is the key

Example config

config  :inflectorex, plural: [
    {~r/developer/ , "developers"},
    {~r/elixir/, "elixirs"}
]  

Todo

  • Implement caching
  • Error handling
  • code commenting
  • tests
  • publishing to hex.pm

Credits

  • CakePHP's inflector
  • degex/inflector

License

MIT

inflector's People

Contributors

girishramnani avatar

Stargazers

Jaeyson Anthony Y. ⚗️ avatar  avatar Dung Nguyen avatar Philip Brown avatar Oleg Blyednov avatar Jacky Alciné avatar Craig Spaeth avatar Tai An Su avatar Taylor Dolezal avatar Adam Kirk avatar Thomas Athanas avatar Byungjik Roh avatar cz avatar Nikos avatar Konrad Oleksiuk avatar  avatar

Watchers

James Cloos avatar  avatar  avatar

inflector's Issues

Make singular/plural definitions extendable

This is important as you'll never be able to cover all possible cases, especially when it comes to jargon and other words that reside around any particular domain.

Here are a few different ways you could do this, I'll let you decide.

  1. Simple additions to the regex: Add a ++ Application.get_env(:inflextorex, :singlular_uninflected, []) to each regex. The user could build a config/inflections.exs which could be imported inside config/config.exs
  2. Make a DSL. Allow the user to do a use on a DSL module you create and then make a macro to add additional definitions. The user would then likely use this new module you've helped them build in order to interface with your package. It may be best to only store in this module the additions and build it to fall back to your current implementation.
  3. A mix of the above two, build a wrapper around Mix.Config which exposes a DSL to add new inflections. Make a mix task to create the config/inflections.exs with some examples and comments and append an import to config/config.exs. Your macro for adding new inflections expands to simple mix config settings.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.