Convert singular word to its plural form.

    Args:
        singular: A word in its singular form.

    Returns:
        The word in its plural form.
335674
def pluralize(singular):
    
    if singular in UNCOUNTABLES:
        return singular
    for i in IRREGULAR:
        if i[0] == singular:
            return i[1]
    for i in PLURALIZE_PATTERNS:
        if re.search(i[0], singular):
            return re.sub(i[0], i[1], singular)
1152255
function singularVerb(phrase) {

  var word = /\w+/.exec(phrase)[0];

  if(word === 'are') {
    phrase = phrase.replace('are', 'is');
  } else if (word.slice(-1) === 'y') {
    phrase = phrase.replace(word, word.slice(0,-1) + 'ies');
  } else {
    phrase = phrase.replace(word, word + 's' );
  }

  return phrase;
}
1160810
public static function plural($word)
    {
        if(is_array($word)) {
            $ret = [];
            foreach($word as $key => $value) {
                $ret[$key] = Str::plural($value);
            }

            return $ret;
        }

        return Inflector::plural($word);
    }
1210282
def plural(self):
		'''  '''

		element = self._first('NN')
		if element:
			if 'kein Plur' in element:
				# There is no plural
				return ['']
			if re.search(', ([\w|\s|/]+)>', element, re.U):
				# Plural form is provided
				return re.findall(', ([\w|\s|/]+)>', element, re.U)[0].split('/')
			if re.search(', -(\w+)>', element, re.U):
				# Suffix is provided
				suffix = re.findall(', -(\w+)>', element, re.U)[0]
				return [self.word + suffix]
			if element.endswith('->'):
				# Plural is the same as singular
				return [self.word]
		return [None]
926907
function stemPluralWord(plural_word){
    var matches = plural_word.match(/^(.*)-(.*)$/);
    if(!matches){
        return plural_word;
    }
    words = [matches[1], matches[2]];

    //malaikat-malaikat-nya -> malaikat malaikat-nya
    suffix = words[1];
    suffixes = ["ku", "mu", "nya", "lah", "kah", "tah", "pun"];
    matches = words[0].match(/^(.*)-(.*)$/);
    if(suffixes.indexOf(suffix) != -1 && matches){
        words[0] = matches[1];
        words[1] = matches[2] + '-' + suffix;
    }

    //berbalas-balasan -> balas
    rootWord1 = stemSingularWord(words[0]);
    rootWord2 = stemSingularWord(words[1]);

    //meniru-nirukan -> tiru
    if(!find(words[1]) && rootWord2==words[1]){
        rootWord2 = stemSingularWord("me" + words[1]);
    }
    if(rootWord1==rootWord2){
        return rootWord1;
    }
    else{
        return plural_word;
    }
}
326401
def _num_plurals(self, catalogue):
        
        match = re.search(r'nplurals=\s*(\d+)', self.get_plural(catalogue) or '')
        if match:
            return int(match.groups()[0])
        return 2
596021
def pluralize(singular=None):
    
    if singular.endswith("y") and not singular.endswith("ay"):
        plural = singular[:-1] + "ies"
    elif singular.endswith("s"):
        plural = singular + "es"
    else:
        plural = singular + "s"
    return plural
1237
private function get_plural_forms() {
        // lets assume message number 0 is header
        // this is true, right?
        $this->load_tables();

        // cache header field for plural forms
        if (!is_string($this->pluralheader)) {
            if ($this->enable_cache) {
                $header = $this->cache_translations[""];
            }
            else {
                $header = $this->get_translation_string(0);
            }
            if (preg_match("/plural\-forms: ([^\n]*)\n/i", $header, $regs))
                $expr = $regs[1];
            else
                $expr = "nplurals=2; plural=n == 1 ? 0 : 1;";
            $this->pluralheader = $expr;
        }
        return $this->pluralheader;
    }
906619
def pluralized_array_from_hash(hash, singular_key, plural_key)
      [].tap do |array|
        value = value_from_singular_key(hash, singular_key)
        value ||= value_from_plural_key(hash, plural_key)
        array << value
      end.flatten.compact
    end
3774
private function pluralize($singular)
    {
        if (null === $this->pluralizer) {
            return $singular;
        }

        return call_user_func($this->pluralizer, $singular);
    }
477699
def convert_msg(self, msg):
        
        source = msg.msgid
        if not source:
            # don't translate empty string
            return

        plural = msg.msgid_plural
        if plural:
            # translate singular and plural
            foreign_single = self.convert(source)
            foreign_plural = self.convert(plural)
            plural = {
                '0': self.final_newline(source, foreign_single),
                '1': self.final_newline(plural, foreign_plural),
            }
            msg.msgstr_plural = plural
        else:
            foreign = self.convert(source)
            msg.msgstr = self.final_newline(source, foreign)
367707
public static function pluralize($word)
    {
        if (isset(self::$_cache['pluralize'][$word])) {
            return self::$_cache['pluralize'][$word];
        }

        if (!isset(self::$_plural['merged']['irregular'])) {
            self::$_plural['merged']['irregular'] = self::$_plural['irregular'];
        }

        if (!isset(self::$_plural['merged']['uninflected'])) {
            self::$_plural['merged']['uninflected'] = array_merge(self::$_plural['uninflected'], self::$_uninflected);
        }

        if (!isset(self::$_plural['cacheUninflected']) || !isset(self::$_plural['cacheIrregular'])) {
            self::$_plural['cacheUninflected'] = '(?:' . implode('|', self::$_plural['merged']['uninflected']) . ')';
            self::$_plural['cacheIrregular'] = '(?:' . implode('|', array_keys(self::$_plural['merged']['irregular'])) . ')';
        }

        if (preg_match('/(.*)\\b(' . self::$_plural['cacheIrregular'] . ')$/i', $word, $regs)) {
            self::$_cache['pluralize'][$word] = $regs[1] . substr($word, 0, 1) . substr(self::$_plural['merged']['irregular'][strtolower($regs[2])], 1);
            return self::$_cache['pluralize'][$word];
        }

        if (preg_match('/^(' . self::$_plural['cacheUninflected'] . ')$/i', $word, $regs)) {
            self::$_cache['pluralize'][$word] = $word;
            return $word;
        }

        foreach (self::$_plural['rules'] as $rule => $replacement) {
            if (preg_match($rule, $word)) {
                self::$_cache['pluralize'][$word] = preg_replace($rule, $replacement, $word);
                return self::$_cache['pluralize'][$word];
            }
        }
    }
557195
def _irregular(singular, plural):
    
    def caseinsensitive(string):
        return ''.join('[' + char + char.upper() + ']' for char in string)

    if singular[0].upper() == plural[0].upper():
        PLURALS.insert(0, (
            r"(?i)({}){}$".format(singular[0], singular[1:]),
            r'\1' + plural[1:]
        ))
        PLURALS.insert(0, (
            r"(?i)({}){}$".format(plural[0], plural[1:]),
            r'\1' + plural[1:]
        ))
        SINGULARS.insert(0, (
            r"(?i)({}){}$".format(plural[0], plural[1:]),
            r'\1' + singular[1:]
        ))
    else:
        PLURALS.insert(0, (
            r"{}{}$".format(singular[0].upper(),
                            caseinsensitive(singular[1:])),
            plural[0].upper() + plural[1:]
        ))
        PLURALS.insert(0, (
            r"{}{}$".format(singular[0].lower(),
                            caseinsensitive(singular[1:])),
            plural[0].lower() + plural[1:]
        ))
        PLURALS.insert(0, (
            r"{}{}$".format(plural[0].upper(), caseinsensitive(plural[1:])),
            plural[0].upper() + plural[1:]
        ))
        PLURALS.insert(0, (
            r"{}{}$".format(plural[0].lower(), caseinsensitive(plural[1:])),
            plural[0].lower() + plural[1:]
        ))
        SINGULARS.insert(0, (
            r"{}{}$".format(plural[0].upper(), caseinsensitive(plural[1:])),
            singular[0].upper() + singular[1:]
        ))
        SINGULARS.insert(0, (
            r"{}{}$".format(plural[0].lower(), caseinsensitive(plural[1:])),
            singular[0].lower() + singular[1:]
        ))
797842
public static function singular(string $word) : string
    {
        // Check that `$word` is countable.
        if(in_array($word, Inflector::$_uncontable)) {
            return $word;
        }

        // Now check that `$word` is regular.
        if(isset(Inflector::$_singular["irregular"][$word])) {
            return Inflector::$_singular["irregular"][$word];
        }

        // Now check that `$word` can be singularize.
        foreach(Inflector::$_singular["uninflected"] as $rule) {
            if(preg_match("/^". $rule ."$/", $word)) {
                return $word;
            }
        }

        // Now the word follows a rule, so apply it
        foreach(Inflector::$_singular["rules"] as $key => $value) {
            if(preg_match($key, $word)) {
                return preg_replace($key, $value, $word);
            }
        }

        // Well, right now the word couldn't be singularized
        // so return it as it was (or throw an exception?)
        return $word;
    }
935364
public static function pluralize($word)
    {
        //Get the cached noun of it exists
        if(isset(self::$_cache['pluralized'][$word])) {
            return self::$_cache['pluralized'][$word];
        }

        //Create the plural noun
        if (in_array($word, self::$_rules['countable'])) {
            self::$_cache['pluralized'][$word] = $word;
            return $word;
        }

        foreach (self::$_rules['pluralization'] as $regexp => $replacement)
        {
            $matches = null;
            $plural = preg_replace($regexp, $replacement, $word, -1, $matches);
            if ($matches > 0) {
                self::$_cache['pluralized'][$word] = $plural;
                return $plural;
            }
        }

        return $word;
    }
552091
public static function plural(string $word) : string
    {
        // Check that `$word` is countable.
        if(in_array($word, Inflector::$_uncontable)) {
            return $word;
        }

        // Now check that `$word` is regular.
        if(isset(Inflector::$_plural["irregular"][$word])) {
            return Inflector::$_plural["irregular"][$word];
        }

        // Now check that `$word` can be pluralize.
        foreach(Inflector::$_plural["uninflected"] as $rule) {
            if(preg_match("/^". $rule ."$/", $word)) {
                return $word;
            }
        }

        // Now the word follows a rule, so apply it
        foreach(Inflector::$_plural["rules"] as $key => $value) {
            if(preg_match($key, $word)) {
                return preg_replace($key, $value, $word);
            }
        }

        // Well, right now the word couldn't be pluralized
        // so return it as it was (or throw an exception?)
        return $word;
    }
907434
public static String singularize(String word) {
        if (isUncountable(word)) {
            return word;
        } else {
            for (Inflection inflection : SINGULAR) {
                if (inflection.match(word)) {
                    return inflection.replace(word);
                }
            }
        }
        return word;
    }