Skip to content

Add some more non-countable English nouns #52526

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 28 additions & 10 deletions src/Symfony/Component/String/Inflector/EnglishInflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class EnglishInflector implements InflectorInterface
private const PLURAL_MAP = [
// First entry: plural suffix, reversed
// Second entry: length of plural suffix
// Third entry: Whether the suffix may succeed a vocal
// Third entry: Whether the suffix may succeed a vowel
// Fourth entry: Whether the suffix may succeed a consonant
// Fifth entry: singular suffix, normal

Expand Down Expand Up @@ -162,7 +162,7 @@ final class EnglishInflector implements InflectorInterface
private const SINGULAR_MAP = [
// First entry: singular suffix, reversed
// Second entry: length of singular suffix
// Third entry: Whether the suffix may succeed a vocal
// Third entry: Whether the suffix may succeed a vowel
// Fourth entry: Whether the suffix may succeed a consonant
// Fifth entry: plural suffix, normal

Expand Down Expand Up @@ -343,15 +343,30 @@ final class EnglishInflector implements InflectorInterface
// deer
'reed',

// equipment
'tnempiuqe',

// feedback
'kcabdeef',

// fish
'hsif',

// health
'htlaeh',

// history
'yrotsih',

// info
'ofni',

// information
'noitamrofni',

// money
'yenom',

// moose
'esoom',

Expand All @@ -363,6 +378,9 @@ final class EnglishInflector implements InflectorInterface

// species
'seiceps',

// traffic
'ciffart',
];

/**
Expand Down Expand Up @@ -399,14 +417,14 @@ public function singularize(string $plural): array
if ($j === $suffixLength) {
// Is there any character preceding the suffix in the plural string?
if ($j < $pluralLength) {
$nextIsVocal = false !== strpos('aeiou', $lowerPluralRev[$j]);
$nextIsVowel = false !== strpos('aeiou', $lowerPluralRev[$j]);

if (!$map[2] && $nextIsVocal) {
// suffix may not succeed a vocal but next char is one
if (!$map[2] && $nextIsVowel) {
// suffix may not succeed a vowel but next char is one
break;
}

if (!$map[3] && !$nextIsVocal) {
if (!$map[3] && !$nextIsVowel) {
// suffix may not succeed a consonant but next char is one
break;
}
Expand Down Expand Up @@ -479,14 +497,14 @@ public function pluralize(string $singular): array
if ($j === $suffixLength) {
// Is there any character preceding the suffix in the plural string?
if ($j < $singularLength) {
$nextIsVocal = false !== strpos('aeiou', $lowerSingularRev[$j]);
$nextIsVowel = false !== strpos('aeiou', $lowerSingularRev[$j]);

if (!$map[2] && $nextIsVocal) {
// suffix may not succeed a vocal but next char is one
if (!$map[2] && $nextIsVowel) {
// suffix may not succeed a vowel but next char is one
break;
}

if (!$map[3] && !$nextIsVocal) {
if (!$map[3] && !$nextIsVowel) {
// suffix may not succeed a consonant but next char is one
break;
}
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy