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

  • Home
  • SEARCH
  • 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 949925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:28:55+00:00 2026-05-15T23:28:55+00:00

PLURALIZATION_EXCEPTIONS = hardware,’memory’ def pluralize_category_name(name) category = name.split(‘ and ‘) exceptions_to_exp = category.map! {

  • 0
PLURALIZATION_EXCEPTIONS = "hardware",'memory'
def pluralize_category_name(name)
  category = name.split(' and ')
  exceptions_to_exp = ""

  category.map! { |e| 
    if e.match(/^[A-Z]+$/)  and !e.match(/^[A-Z]+S$/)
      e = e.pluralize
    end
    (PLURALIZATION_EXCEPTIONS.include?(e.downcase)  || e.match(/^[A-Z]+S$/) ||
      e.match(/[memory|hardware]/) )? e : e.pluralize
  }.join(' and ')
end

The test should and expectation should be as follows:

it "properly pluralizes hardware as hardware" do
   pluralize_category_name("hardware").should == "hardware"
end

it "properly pluralizes UPS as UPS" do
   pluralize_category_name("UPS").should == "UPS"
end

it "properly pluralizes PDA and Portable Hardware as PDAs and Portable Hardware" do
   pluralize_category_name("PDA and Portable Hardware").should == "PDAs and Portable Hardware"
end

it "properly pluralizes perfume and cologne as perfumes and colognes" do
   pluralize_category_name("perfume and cologne").should == "perfumes and colognes"
end

The last test fails 🙁

HELP!

  • 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-05-15T23:28:56+00:00Added an answer on May 15, 2026 at 11:28 pm

    I think your problem is that in your condition

    (PLURALIZATION_EXCEPTIONS.include?(e.downcase)  || e.match(/^[A-Z]+S$/) ||
          e.match(/[memory|hardware]/) )? e : e.pluralize
    

    "perfume" matches /[memory|hardware]/.

    [memory|hardware] is a character class that matches any of m, e, m, o, r, etc..

    Perhaps you meant e.match(/(memory|hardware)]/i) instead? This alternative pattern would pass your tests but it doesn’t make use of your PLURALIZATION_EXCEPTIONS constant so would need updating if you added any other exceptions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given an EntityType, such as Contact, how can I derive from it the name
I have a Rails app with a database that has two columns (name and
I have the following model: class Mix private() extends MongoRecord[Mix] with ObjectIdPk[Mix] { def
My entity name is "Contact" and my table name is "Contact". However, the default
Within my application i have a PUBLIC customer class... Public Class Customer Public Name
I am using VS 2010 and I have an entity 'Person'. The pluralization-service turns
I'm building a string based on selected checkboxes. I wrote a statement that will
According to this section in the Django docs I should use {% blocktrans %}
I am using MySQL .net connector 6.4.4.0 and Entity Frame work 4.1 and trying
I`m trying to create a message which uses some kind of pluralization. The message

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.