SpanishInflector
in package
implements
InflectorInterface
FinalYes
Table of Contents
Interfaces
Constants
- PLURALIZE_REGEXP = [ // Specials sí, no ['/(sí|no)$/i', '\1es'], // Words ending with vowel must use -s (RAE 3.2a, 3.2c) ['/(a|e|i|o|u|á|é|í|ó|ú)$/i', '\1s'], // Word ending in s or x and the previous letter is accented (RAE 3.2n) ['/ás$/i', 'ases'], ['/és$/i', 'eses'], ['/ís$/i', 'ises'], ['/ós$/i', 'oses'], ['/ús$/i', 'uses'], // Words ending in -ión must changed to -iones ['/ión$/i', '\1iones'], // Words ending in some consonants must use -es (RAE 3.2k) ['/(l|r|n|d|j|s|x|ch|y)$/i', '\1es'], // Word ending in z, must changed to ces ['/(z)$/i', 'ces'], ]
- A list of all rules for pluralise.
- SINGULARIZE_REGEXP = [ // Specials sí, no ['/(sí|no)es$/i', '\1'], // Words ending in -ión must changed to -iones ['/iones$/i', '\1ión'], // Word ending in z, must changed to ces ['/ces$/i', 'z'], // Word ending in s or x and the previous letter is accented (RAE 3.2n) ['/(\w)ases$/i', '\1ás'], ['/eses$/i', 'és'], ['/ises$/i', 'ís'], ['/(\w{2,})oses$/i', '\1ós'], ['/(\w)uses$/i', '\1ús'], // Words ending in some consonants and -es, must be the consonants ['/(l|r|n|d|j|s|x|ch|y)e?s$/i', '\1'], // Words ended with vowel and s, must be vowel ['/(a|e|i|o|u|á|é|ó|í|ú)s$/i', '\1'], ]
- A list of all rules for singularize.
- UNINFLECTED = '/^(lunes|martes|miércoles|jueves|viernes|análisis|torax|yo|pies)$/i'
- UNINFLECTED_RULES = [ // Words ending with pies (RAE 3.2n) '/.*(piés)$/i', ]
Methods
- pluralize() : array<string|int, string>
- Returns the plural forms of a string.
- singularize() : array<string|int, string>
- Returns the singular forms of a string.
- isInflectedWord() : bool
Constants
PLURALIZE_REGEXP
A list of all rules for pluralise.
private
mixed
PLURALIZE_REGEXP
= [
// Specials sí, no
['/(sí|no)$/i', '\1es'],
// Words ending with vowel must use -s (RAE 3.2a, 3.2c)
['/(a|e|i|o|u|á|é|í|ó|ú)$/i', '\1s'],
// Word ending in s or x and the previous letter is accented (RAE 3.2n)
['/ás$/i', 'ases'],
['/és$/i', 'eses'],
['/ís$/i', 'ises'],
['/ós$/i', 'oses'],
['/ús$/i', 'uses'],
// Words ending in -ión must changed to -iones
['/ión$/i', '\1iones'],
// Words ending in some consonants must use -es (RAE 3.2k)
['/(l|r|n|d|j|s|x|ch|y)$/i', '\1es'],
// Word ending in z, must changed to ces
['/(z)$/i', 'ces'],
]
Tags
SINGULARIZE_REGEXP
A list of all rules for singularize.
private
mixed
SINGULARIZE_REGEXP
= [
// Specials sí, no
['/(sí|no)es$/i', '\1'],
// Words ending in -ión must changed to -iones
['/iones$/i', '\1ión'],
// Word ending in z, must changed to ces
['/ces$/i', 'z'],
// Word ending in s or x and the previous letter is accented (RAE 3.2n)
['/(\w)ases$/i', '\1ás'],
['/eses$/i', 'és'],
['/ises$/i', 'ís'],
['/(\w{2,})oses$/i', '\1ós'],
['/(\w)uses$/i', '\1ús'],
// Words ending in some consonants and -es, must be the consonants
['/(l|r|n|d|j|s|x|ch|y)e?s$/i', '\1'],
// Words ended with vowel and s, must be vowel
['/(a|e|i|o|u|á|é|ó|í|ú)s$/i', '\1'],
]
UNINFLECTED
private
mixed
UNINFLECTED
= '/^(lunes|martes|miércoles|jueves|viernes|análisis|torax|yo|pies)$/i'
UNINFLECTED_RULES
private
mixed
UNINFLECTED_RULES
= [
// Words ending with pies (RAE 3.2n)
'/.*(piés)$/i',
]
Methods
pluralize()
Returns the plural forms of a string.
public
pluralize(string $singular) : array<string|int, string>
If the method can't determine the form with certainty, several possible plurals are returned.
Parameters
- $singular : string
Return values
array<string|int, string>singularize()
Returns the singular forms of a string.
public
singularize(string $plural) : array<string|int, string>
If the method can't determine the form with certainty, several possible singulars are returned.
Parameters
- $plural : string
Return values
array<string|int, string>isInflectedWord()
private
isInflectedWord(string $word) : bool
Parameters
- $word : string