Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #789 (closed defect: wontfix)

Opened 3 years ago

Last modified 7 months ago

Inflector: plural_rules Additions Corrections

Reported by: amitchell@ttcent.com Assigned to: David
Priority: low Milestone: 1.0
Component: ActiveSupport Version: 0.12.1
Severity: trivial Keywords: pluralize
Cc:

Description

Following are additional pluralization rules, written patch-like into the source for vendor/activesupport/lib/active_support/inflector.rb for plural_rules method. Online documentation provided the line numbers used.

60:         [/(x|ch|ss|sh)$/, '\1es'],            # search, switch, fix, box, process, address, phalanx(military)
61:         [/series$/, '\1series'],
#line 62 is considered questionable
62:         [/([^aeiouy]|qu)ies$/, '\1y'],        # congeries(singular)
63:         [/([^aeiouy]|qu)y$/, '\1ies'],        # query, ability, agency
64:         [/(?:([^f])fe|([lr])f)$/, '\1\2ves'], # half, safe, wife
65:         [/sis$/, 'ses'],                      # basis, diagnosis
            [/ceps$/, 'cepses'],                  # biceps, tricep, quadraceps, forceps are all singuler

            [/iris$/, 'irides'],                  # correct, but not in common use
            [/is$/, 'ises'],                      # correct for most declensions
            [/is$/, 'es'],                        # correct for remainder

            [/apparatus$/, 'apparatus'],
            [/genus$/, 'genera'],
            [/opus$/, 'opera'],                   # opera has dual plurals, also operae, operas.
            [/octopus$/, 'octopodes'],            # octopi is wrong, octopus is not a second declension noun

            [/us$/, 'i'],                         # correct for second declension nouns, focus(mathematical), crocus, isthmus, ignoramus, mandamus
            [/us$/, 'uses'],                      # correct for other declension nouns, focus(purpose of investigation), fetus, census, sinus, hiatus, virus, walrus, talus


            [/os$/, 'oses'],                      # OSes, rhinoceroses(rhinocerontes actually)

            [/quorum$/, 'quorums'],               # important rule
66:         [/([ti])um$/, '\1a'],                 # datum, medium
            [/([ilrt])um$/, '\1a'],               # datum, medium(presentation)*, bacterium, phylum, forum
            [/um$/, 'ums'],                       # gymnasiums, forum, medium(person)

            [/ph$/, 'phs'],                       # photograph
            [/ph$/, 'phim'],                      # seraph

            [/on$/, 'a'],                         # phenomenon, ganglion, automaton, criterion

            [/nn$/, 'nni'],                      # djinni, jinni


#!! shadowed by rules above
            [/phalanx$/, 'phalanges'],            # phalanx(fingers, toes)
            [/x$/, 'xen'],                        # ox, and a few others
            [/mos$/, 'mores'],                    # mos
            [/viscus$/, 'viscera'],               # viscus
            [/fex$/, 'feces'],                    # fex
            [/necropolis$/, 'necropoli'],         # necropolis

            [/goy$/, 'goyim'],
            [/matzo$/, 'matzot'],
            [/insigne$/, 'insignia'],
            [/ragale$/, 'regalia'],
            [/exemplar$/, 'exemplaria'],
            [/paraphernal$/, 'paraphernalia'],
67:         [/person$/, 'people'],                # person, salesperson

#exceptions to rule 68
# caiman, doberman, German, human, leman, ottoman, pitman, Pullman, Roman, shaman, talisman
68:         [/man$/, 'men'],                      # man, woman, spokesman
69:         [/child$/, 'children'],               # child
70:         [/s$/, 's'],                          # no change (compatibility)
71:         [/$/, 's']

There are several conflicts in the above rules. But incorporation of some of the above, will make inflection better.

There are many plurals that cannot be correctly singularized. axes could have come from axe, or axis; bases: base, basis; ellipses: ellipse, ellipsis.

Change History

03/08/05 00:21:40 changed by michael@koziarski.com

  • milestone set to 1.0.

03/12/05 06:41:47 changed by ulysses

Although perhaps valid from a linguistical standpoint, I see some cases that are without value. For example, I cannot forsee the day when I have a 'germans' table in my database. ;)

03/24/05 20:29:25 changed by flgr

In the original rules I tried to optimize for common cases that make most sense with RubyOnRails. If there's any important cases where they fail I'd suggest listimg them in as few rules as possible (group similar things together) above the questionable rules.

Singular -> Plural is also easier than Plural -> Singular as you noted above, but I guess we can still try to do the best thing in most cases.

I still believe strongly that it can not be done totally correct in all cases, but the harder we try to minimize surprises in relevant cases the better it is.

04/12/05 01:47:02 changed by david.tulloh@infaze.com.au

Quiz --> Quizes (currently Quizs)

04/12/05 06:11:17 changed by anonymous

my dictionary shows Quiz --> Quizzes

04/14/05 20:57:39 changed by david.tulloh@infaze.com.au

You are right (that was painful to fix)

I scanned a word list to try to find other words ending in z but there was nothing that looked like a singular normal word.

I added the lines: \1\2zes,

\1z,

04/29/05 14:59:32 changed by anonymous

  • version changed from 0.10.0 to 0.12.1.

I'm trying to use a table called Statuses and at this point the conversion between Status to Statuses doesn't seem to work. Because the wonderful lack of consistency in English, it would be helpful there was a generator recognized way to specifiying this data, maybe as a parameter. That would also help out non English speakers as well.

06/14/05 20:11:02 changed by bitsweat

  • status changed from new to closed.
  • resolution set to wontfix.

The inflector is meant to handle common cases easily; it is not exhaustive and shouldn't be. These are mostly rare words better handled by specifying custom table names as needed.

12/14/07 19:35:46 changed by pinkboi

The correct plural is octopuses, not octopedes because octopus is not a Latin word (it's Greek). Octopodes is the plural for octoped, which is what it would be if it was Latin.

I think octopus is sufficiently common that at least it and a few other words he mentioned could justify inclusion.