Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8458831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:11:05+00:00 2026-06-10T13:11:05+00:00

I haven’t found a good library actionscript library for this yet. I want to

  • 0

I haven’t found a good library actionscript library for this yet.

I want to do things like:

Inflection.pluralize( "cat" ) == "cats"
Inflection.pluralize( "fish" ) == "fish"

I know ruby on rails has a library like this build in; and javascript has a really nice one as well: http://code.google.com/p/inflection-js/.

Any one know of a similar thing for actionscript?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T13:11:07+00:00Added an answer on June 10, 2026 at 1:11 pm

    Google says:
    http://kuwamoto.org/2007/12/17/improved-pluralizing-in-php-actionscript-and-ror/

    package
    {
    public class Inflect
    {
        private static var plural : Array = [
            [/(quiz)$/i,                     "$1zes"],
            [/^(ox)$/i,                      "$1en"],
            [/([m|l])ouse$/i,                "$1ice"],
            [/(matr|vert|ind)ix|ex$/i,       "$1ices"],
            [/(x|ch|ss|sh)$/i,               "$1es"],
            [/([^aeiouy]|qu)y$/i,            "$1ies"],
            [/(hive)$/i,                     "$1s"],
            [/(?:([^f])fe|([lr])f)$/i,       "$1$2ves"],
            [/(shea|lea|loa|thie)f$/i,       "$1ves"],
            [/sis$/i,                        "ses"],
            [/([ti])um$/i,                   "$1a"],
            [/(tomat|potat|ech|her|vet)o$/i, "$1oes"],
            [/(bu)s$/i,                      "$1ses"],
            [/(alias|status)$/i,             "$1es"],
            [/(octop)us$/i,                  "$1i"],
            [/(ax|test)is$/i,                "$1es"],
            [/(us)$/i,                       "$1es"],
            [/s$/i,                          "s"],
            [/$/i,                           "s"]
        ];
    
        private static var singular : Array = [
            [/(quiz)zes$/i,             "$1"],
            [/(matr)ices$/i,            "$1ix"],
            [/(vert|ind)ices$/i,        "$1ex"],
            [/^(ox)en$/i,               "$1"],
            [/(alias|status)es$/i,      "$1"],
            [/(octop|vir)i$/i,          "$1us"],
            [/(cris|ax|test)es$/i,      "$1is"],
            [/(shoe)s$/i,               "$1"],
            [/(o)es$/i,                 "$1"],
            [/(bus)es$/i,               "$1"],
            [/([m|l])ice$/i,            "$1ouse"],
            [/(x|ch|ss|sh)es$/i,        "$1"],
            [/(m)ovies$/i,              "$1ovie"],
            [/(s)eries$/i,              "$1eries"],
            [/([^aeiouy]|qu)ies$/i,     "$1y"],
            [/([lr])ves$/i,             "$1f"],
            [/(tive)s$/i,               "$1"],
            [/(hive)s$/i,               "$1"],
            [/(li|wi|kni)ves$/i,        "$1fe"],
            [/(shea|loa|lea|thie)ves$/i,"$1f"],
            [/(^analy)ses$/i,           "$1sis"],
            [/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i,  "$1$2sis"],
            [/([ti])a$/i,               "$1um"],
            [/(n)ews$/i,                "$1ews"],
            [/(h|bl)ouses$/i,           "$1ouse"],
            [/(corpse)s$/i,             "$1"],
            [/(us)es$/i,                "$1"],
            [/s$/i,                     ""]
        ];
    
        private static var irregular : Array = [
            ['move'   , 'moves'],
            ['foot'   , 'feet'],
            ['goose'  , 'geese'],
            ['sex'    , 'sexes'],
            ['child'  , 'children'],
            ['man'    , 'men'],
            ['tooth'  , 'teeth'],
            ['person' , 'people']
        ];
    
        private static var uncountable : Array = [
            'sheep',
            'fish',
            'deer',
            'series',
            'species',
            'money',
            'rice',
            'information',
            'equipment'
        ];
    
        public static function pluralize( string : String ) : String
        {
            var pattern : RegExp;
            var result : String;
    
            // save some time in the case that singular and plural are the same
            if (uncountable.indexOf(string.toLowerCase()) != -1)
              return string;
    
            // check for irregular singular forms
            var item : Array;
            for each ( item in irregular )
            {
                pattern = new RegExp(item[0] + "$", "i");
                result = item[1];
    
                if (pattern.test(string))
                {
                    return string.replace(pattern, result);
                }
            }
    
            // check for matches using regular expressions
            for each ( item in plural)
            {
                pattern = item[0];
                result = item[1];
    
                if (pattern.test(string))
                {
                    return string.replace(pattern, result);
                }
            }
    
            return string;
        }
    
        public static function singularize( string : String ) : String
        {
            var pattern : RegExp;
            var result : String
    
            // save some time in the case that singular and plural are the same
            if (uncountable.indexOf(string.toLowerCase()) != -1)
                return string;
    
            // check for irregular singular forms
            var item : Array;
            for each ( item in irregular )
            {
                pattern = new RegExp(item[1] + "$", "i");
                result = item[0];
    
                if (pattern.test(string))
                {
                    return string.replace(pattern, result);
                }
           }
    
           // check for matches using regular expressions
           for each ( item in singular)
           {
                pattern = item[0];
                result = item[1];
    
                if (pattern.test(string))
                {
                    return string.replace(pattern, result);
                }
           }
    
           return string;
    
        }
    
        public static function pluralizeIf(count : int, string : String) : String
        {
            if (count == 1)
                return "1 " + string;
            else
                return count.toString() + " " + pluralize(string);
        }
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Haven't found a solution to this problem yet, have tried some things... I have
I haven't found a definite answer to this yet. Lots of apps let you
I haven't found any documentation on this or seen this done before, but is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Haven't found what i'm looking for so far. I want to redirect all my
Haven't found this in my search on Stackoverflow - I know I've seen a
I haven't found a solution yet in StackOverlfow to my problem. I'm using nl2br()
Haven't seen many Geneva related questions yet, I have posted this question in the
Haven't done serious JavaScript since 90s, so looks like a couple of things changed.
Haven't found in docs. Does java ResultSet supports query arguments,like jdbcTemplate? For example, something

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.