A convenience function to add appropriate rules to plurals and singular
    for irregular words.

    :param singular: irregular word in singular form
    :param plural: irregular word in plural form
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:]
        ))
881914
public static function pluralise($word)
    {
        // Run each rule over the word
        foreach (static::$pluralRules as $rule => $replacement) {
            if (preg_match($rule, $word)) {
                return preg_replace($rule, $replacement, $word);
            }
        }

        return $word;
    }
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
1277360
def inflect(word: str,
            count: int):
    
    if word in ['time', 'sentence']:
        return word if count == 1 else word + 's'
    elif word == 'was':
        return 'was' if count == 1 else 'were'
    else:
        return word + '(s)'
715953
function createRules() {
  const rules = {};
  sets.forEach((set) => {
    set.lngs.forEach((l) => {
      rules[l] = {
        numbers: set.nr,
        plurals: _rulesPluralsTypes[set.fc]
      };
    });
  });
  return rules;
}
173042
def plural(self, text, count=None):
        
        pre, word, post = self.partition_word(text)
        if not word:
            return text
        plural = self.postprocess(
            word,
            self._pl_special_adjective(word, count)
            or self._pl_special_verb(word, count)
            or self._plnoun(word, count),
        )
        return "{}{}{}".format(pre, plural, post)
991225
def rule_factory(plural, singular):
    """"""
    @rules.rule(plural)
    def f(path, values):
        for v in values:
            if v:
                elem = etree.Element(
                    '{{http://purl.org/dc/elements/1.1/}}{0}'.format(singular))
                elem.text = v
                yield elem
    f.__name__ = plural
    return f
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
491648
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 ];
			}
		}
	}
233952
def as_plural(result_key):
    
    # Not at all guaranteed to work in all cases...
    if result_key.endswith('y'):
        return re.sub("y$", "ies", result_key)
    elif result_key.endswith('address'):
        return result_key + 'es'
    elif result_key.endswith('us'):
        return re.sub("us$", "uses", result_key)
    elif not result_key.endswith('s'):
        return result_key + 's'
    else:
        return result_key
3774
private function pluralize($singular)
    {
        if (null === $this->pluralizer) {
            return $singular;
        }

        return call_user_func($this->pluralizer, $singular);
    }
1063552
protected function generateRulesets()
    {
        $model = $this->cldrRepository->getModel('supplemental/plurals');
        $pluralRulesSet = $model->getRawArray('plurals');

        $index = 0;
        foreach ($pluralRulesSet as $pluralRulesNodeString => $pluralRules) {
            $localeLanguages = $model->getAttributeValue($pluralRulesNodeString, 'locales');

            foreach (explode(' ', $localeLanguages) as $localeLanguage) {
                $this->rulesetsIndices[$localeLanguage] = $index;
            }

            if (is_array($pluralRules)) {
                $ruleset = [];
                foreach ($pluralRules as $pluralRuleNodeString => $pluralRule) {
                    $pluralForm = $model->getAttributeValue($pluralRuleNodeString, 'count');
                    $ruleset[$pluralForm] = $this->parseRule($pluralRule);
                }

                foreach (explode(' ', $localeLanguages) as $localeLanguage) {
                    $this->rulesets[$localeLanguage][$index] = $ruleset;
                }
            }

            ++$index;
        }
    }
202070
def Plural(format_str):
  
  if format_str.startswith('plural?'):
    i = len('plural?')

    try:
      splitchar = format_str[i]  # Usually a space, but could be something else
      _, plural_val, singular_val = format_str.split(splitchar)
    except IndexError:
      raise Error('plural? must have exactly 2 arguments')

    def Formatter(value):
      plural = False
      if isinstance(value, int) and value > 1:
        plural = True
      if isinstance(value, list) and len(value) > 1:
        plural = True

      if plural:
        return plural_val
      else:
        return singular_val

    return Formatter

  else:
    return None
775163
function properize(word, options) {
  options = _.extend({inflect: false}, options);
  if (!/\./.test(word)) {
    word = changeCase(word);
    if (options.inflect === false) {
      return word;
    }
    return inflection.singularize(word);
  }
  return word;
}
901900
def articles(self):
		'''  '''

		result = [None, None]
		element = self._first('NN')
		if element:
			result[0] = [element.split(' ')[0].replace('(die)', '').strip()]
			if 'kein Plur' in element:
				# There is no plural
				result[1] = ['']
			else:
				# If a plural form exists, there is only one possibility
				result[1] = ['die']
		return result
440076
def name_plural(self):
        """"""
        return "freshmen" if (self._number and self._number == 9) else "{}s".format(self._name) if self._name else ""
74821
public function defaultLabels($plural, $singular, $hierarchical = true)
    {
        $labels = [
            'name' => $plural,
            'singular_name' => $singular,
            'menu_name' => $plural,
            'all_items' => $plural,

            'search_items' => Translate::t('term.labels.search_items'),
            'edit_item' => Translate::t('term.labels.edit_item'),
            'update_item' => Translate::t('term.labels.update_item'),
            'add_new_item' => Translate::t('term.labels.add_new_item'),
            'new_item_name' => Translate::t('term.labels.new_item_name'),
        ];

        if ($hierarchical) {
            $labels = array_merge($labels, [
                'parent_item' => Translate::t('term.labels.parent_item'),
                'parent_item_colon' => Translate::t('term.labels.parent_item_colon'),
            ]);
        } else {
            $labels = array_merge($labels, [
                'parent_item' => null,
                'parent_item_colon' => null,

                'popular_items' => Translate::t('term.labels.popular_items'),
                'separate_items_with_commas' => Translate::t('term.labels.separate_items_with_commas'),
                'choose_from_most_used' => Translate::t('term.labels.choose_from_most_used'),

                'add_or_remove_items' => Translate::t('term.labels.add_or_remove_items'),
                'not_found' => Translate::t('term.labels.not_found'),
            ]);
        }

        return $labels;
    }