-
-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
346 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ you want to create an inflector for to the ``createForLanguage()`` method: | |
The supported languages are as follows: | ||
|
||
- ``Language::DUTCH`` | ||
- ``Language::ENGLISH`` | ||
- ``Language::FRENCH`` | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
greg0ire
Member
|
||
- ``Language::NORWEGIAN_BOKMAL`` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Inflector\Rules\Dutch; | ||
|
||
use Doctrine\Inflector\Rules\Pattern; | ||
use Doctrine\Inflector\Rules\Substitution; | ||
use Doctrine\Inflector\Rules\Transformation; | ||
use Doctrine\Inflector\Rules\Word; | ||
|
||
/** | ||
* // http://nl.wikipedia.org/wiki/Klinker_(klank) | ||
* private $klinker = '(a|e|i|o|u|ij)'; | ||
* private $korteKlinker = '(u|i|e|a|o)'; // @todo '(ie|oe)'. $plofKlank | ||
* | ||
* // http://nl.wikipedia.org/wiki/Medeklinker | ||
* private $plofKlank = '(p|t|k|b|d)'; | ||
* private $wrijfKlank = '(f|s|ch|sj|v|z|g|j)'; // journaal | ||
* private $neusKlank = '(m|n|ng)'; | ||
* private $vloeiKlank = '(l|r)'; | ||
* private $glijKlank = '(j|w)'; // jaar | ||
* private $affricate = '(ts|zz|tsj|g)'; // /d3/ gin | ||
* private $missingFromWiki = '(c|h|p|q|x|y|z)'; | ||
* | ||
* public function __construct() | ||
* { | ||
* $this->medeklinker = '(' . $this->missingFromWiki . '|' . $this->plofKlank . '|' . $this->wrijfKlank . '|' . $this->neusKlank . '|' . $this->vloeiKlank . '|' . $this->glijKlank . '|' . $this->affricate . ')'; | ||
* $this->medeklinker = '((c|h|p|q|x|y|z)|(p|t|k|b|d)|(f|s|ch|sj|v|z|g|j)|(m|n|ng)|(l|r)|(j|w)|(ts|zz|tsj|g))'; | ||
* } | ||
*/ | ||
class Inflectible | ||
{ | ||
/** | ||
* @return Transformation[] | ||
*/ | ||
public static function getSingular(): iterable | ||
{ | ||
// http://nl.wikipedia.org/wiki/Meervoud_(Nederlands)#Klinkerverandering | ||
yield new Transformation(new Pattern('()heden$'), '\1heid'); | ||
|
||
// http://nl.wikipedia.org/wiki/Meervoud_(Nederlands)#Beroepen_eindigend_op_-man | ||
yield new Transformation(new Pattern('()mannen$'), '\1man'); | ||
|
||
// http://nl.wikipedia.org/wiki/Meervoud_(Nederlands)#Latijnse_meervoudsvormen | ||
yield new Transformation(new Pattern('()ices$'), '\1ex'); | ||
|
||
// http://nl.wikipedia.org/wiki/Meervoud_(Nederlands)#Stapelmeervoud | ||
yield new Transformation(new Pattern('^(ei|gemoed|goed|hoen|kind|lied|rad|rund)eren$'), '\1'); | ||
|
||
// http://nl.wikipedia.org/wiki/Nederlandse_grammatica | ||
yield new Transformation(new Pattern('()ijen$'), '\1ij'); | ||
|
||
yield new Transformation(new Pattern('()ieen$'), '\1ie'); // ën | ||
|
||
yield new Transformation(new Pattern('()((a|e|i|o|u|ij))s$'), '\1\2'); | ||
|
||
yield new Transformation(new Pattern('()((s)s)en$'), '\1s'); | ||
|
||
yield new Transformation(new Pattern('()((c|h|p|q|x|y|z)|(p|t|k|b|d)|(f|s|ch|sj|v|z|g|j)|(m|n|ng)|(l|r)|(j|w)|(ts|zz|tsj|g))en$'), '\1\2'); | ||
} | ||
|
||
/** | ||
* @return Transformation[] | ||
*/ | ||
public static function getPlural(): iterable | ||
{ | ||
// @todo already in plural (?) | ||
// @todo refine | ||
yield new Transformation(new Pattern('()(e)(s)$'), '\1\2\3\3en'); | ||
|
||
// http://nl.wikipedia.org/wiki/Meervoud_(Nederlands)#Klinkerverandering | ||
yield new Transformation(new Pattern('()heid$'), '\1heden'); | ||
|
||
// http://nl.wikipedia.org/wiki/Meervoud_(Nederlands)#Beroepen_eindigend_op_-man | ||
yield new Transformation(new Pattern('()man$'), '\1mannen'); | ||
|
||
// http://nl.wikipedia.org/wiki/Meervoud_(Nederlands)#Latijnse_meervoudsvormen | ||
yield new Transformation(new Pattern('()ix$'), '\1ices'); | ||
|
||
yield new Transformation(new Pattern('()ex$'), '\1ices'); | ||
|
||
// http://nl.wikipedia.org/wiki/Meervoud_(Nederlands)#Stapelmeervoud | ||
yield new Transformation(new Pattern('^(ei|gemoed|goed|hoen|kind|lied|rad|rund)$'), '\1eren'); | ||
|
||
// http://nl.wikipedia.org/wiki/Nederlandse_grammatica | ||
yield new Transformation(new Pattern('()ij$'), '\1ijen'); | ||
|
||
yield new Transformation(new Pattern('()orie$'), '\1orieen'); // ën klemtoon | ||
|
||
yield new Transformation(new Pattern('()io$'), '\1io\'s'); | ||
|
||
yield new Transformation(new Pattern('()(a|e|i|o|u|ij)$'), '\1\2s'); | ||
|
||
yield new Transformation(new Pattern('()(((c|h|p|q|x|y|z)|(p|t|k|b|d)|(f|s|ch|sj|v|z|g|j)|(m|n|ng)|(l|r)|(j|w)|(ts|zz|tsj|g))e((c|h|p|q|x|y|z)|(p|t|k|b|d)|(f|s|ch|sj|v|z|g|j)|(m|n|ng)|(l|r)|(j|w)|(ts|zz|tsj|g)))$'), '\1\2s'); | ||
|
||
yield new Transformation(new Pattern('()(((c|h|p|q|x|y|z)|(p|t|k|b|d)|(f|s|ch|sj|v|z|g|j)|(m|n|ng)|(l|r)|(j|w)|(ts|zz|tsj|g))(u|i|e|a|o)s)$'), '\1\2sen'); | ||
|
||
yield new Transformation(new Pattern('()(((c|h|p|q|x|y|z)|(p|t|k|b|d)|(f|s|ch|sj|v|z|g|j)|(m|n|ng)|(l|r)|(j|w)|(ts|zz|tsj|g))s)$'), '\1\2en'); | ||
|
||
yield new Transformation(new Pattern('()s$'), '\1zen'); | ||
|
||
yield new Transformation(new Pattern('()((c|h|p|q|x|y|z)|(p|t|k|b|d)|(f|s|ch|sj|v|z|g|j)|(m|n|ng)|(l|r)|(j|w)|(ts|zz|tsj|g))$'), '\1\2en'); | ||
} | ||
|
||
/** | ||
* @return Substitution[] | ||
*/ | ||
public static function getIrregular(): iterable | ||
{ | ||
// http://nl.wikipedia.org/wiki/Klemtoon | ||
yield new Substitution(new Word('olie'), new Word('oliën')); | ||
|
||
yield new Substitution(new Word('industrie'), new Word('industrieën')); | ||
|
||
// http://nl.wikipedia.org/wiki/Meervoud_(Nederlands)#Klinkerverandering | ||
yield new Substitution(new Word('lid'), new Word('leden')); | ||
|
||
yield new Substitution(new Word('smid'), new Word('smeden')); | ||
|
||
yield new Substitution(new Word('schip'), new Word('schepen')); | ||
|
||
yield new Substitution(new Word('stad'), new Word('steden')); | ||
|
||
yield new Substitution(new Word('gelid'), new Word('gelederen')); | ||
|
||
// http://nl.wikipedia.org/wiki/Meervoud_(Nederlands)#Stapelmeervoud | ||
yield new Substitution(new Word('gelid'), new Word('gelederen')); | ||
|
||
yield new Substitution(new Word('kalf'), new Word('kalveren')); | ||
|
||
yield new Substitution(new Word('lam'), new Word('lammeren')); | ||
|
||
// http://nl.wikipedia.org/wiki/Meervoud_(Nederlands)#Onregelmatige_meervoudsvorming | ||
yield new Substitution(new Word('koe'), new Word('koeien')); | ||
|
||
yield new Substitution(new Word('vlo'), new Word('vlooien')); | ||
|
||
yield new Substitution(new Word('leerrede'), new Word('leerredenen')); | ||
|
||
yield new Substitution(new Word('lende'), new Word('lendenen')); | ||
|
||
yield new Substitution(new Word('epos'), new Word('epen')); | ||
|
||
yield new Substitution(new Word('genius'), new Word('geniën')); | ||
|
||
yield new Substitution(new Word('aanbod'), new Word('aanbiedingen')); | ||
|
||
yield new Substitution(new Word('beleg'), new Word('belegeringen')); | ||
|
||
yield new Substitution(new Word('dank'), new Word('dankbetuigingen')); | ||
|
||
yield new Substitution(new Word('gedrag'), new Word('gedragingen')); | ||
|
||
yield new Substitution(new Word('genot'), new Word('genietingen')); | ||
|
||
yield new Substitution(new Word('lof'), new Word('lofbetuigingen')); | ||
|
||
// http://nl.wikipedia.org/wiki/Meervoud_(Nederlands)#Latijnse_meervoudsvormen | ||
yield new Substitution(new Word('qaestrices'), new Word('quaestrix')); | ||
|
||
yield new Substitution(new Word('matrices'), new Word('matrix')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Inflector\Rules\Dutch; | ||
|
||
use Doctrine\Inflector\GenericLanguageInflectorFactory; | ||
use Doctrine\Inflector\Rules\Ruleset; | ||
|
||
final class InflectorFactory extends GenericLanguageInflectorFactory | ||
{ | ||
protected function getSingularRuleset(): Ruleset | ||
{ | ||
return Rules::getSingularRuleset(); | ||
} | ||
|
||
protected function getPluralRuleset(): Ruleset | ||
{ | ||
return Rules::getPluralRuleset(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Inflector\Rules\Dutch; | ||
|
||
use Doctrine\Inflector\Rules\Patterns; | ||
use Doctrine\Inflector\Rules\Ruleset; | ||
use Doctrine\Inflector\Rules\Substitutions; | ||
use Doctrine\Inflector\Rules\Transformations; | ||
|
||
final class Rules | ||
{ | ||
public static function getSingularRuleset(): Ruleset | ||
{ | ||
return new Ruleset( | ||
new Transformations(...Inflectible::getSingular()), | ||
new Patterns(...Uninflected::getSingular()), | ||
(new Substitutions(...Inflectible::getIrregular()))->getFlippedSubstitutions() | ||
); | ||
} | ||
|
||
public static function getPluralRuleset(): Ruleset | ||
{ | ||
return new Ruleset( | ||
new Transformations(...Inflectible::getPlural()), | ||
new Patterns(...Uninflected::getPlural()), | ||
new Substitutions(...Inflectible::getIrregular()) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Inflector\Rules\Dutch; | ||
|
||
use Doctrine\Inflector\Rules\Pattern; | ||
|
||
final class Uninflected | ||
{ | ||
/** | ||
* @return Pattern[] | ||
*/ | ||
public static function getSingular(): iterable | ||
{ | ||
yield from self::getDefault(); | ||
|
||
// http://nl.wikipedia.org/wiki/Plurale_tantum | ||
yield new Pattern('hersenen'); | ||
yield new Pattern('ingewanden'); | ||
yield new Pattern('mazelen'); | ||
yield new Pattern('pokken'); | ||
yield new Pattern('waterpokken'); | ||
yield new Pattern('financiën'); | ||
yield new Pattern('activa'); | ||
yield new Pattern('passiva'); | ||
yield new Pattern('onkosten'); | ||
yield new Pattern('kosten'); | ||
yield new Pattern('bescheiden'); | ||
yield new Pattern('paperassen'); | ||
yield new Pattern('notulen'); | ||
yield new Pattern('Roma'); | ||
yield new Pattern('Sinti'); | ||
yield new Pattern('Inuit'); | ||
yield new Pattern('taliban'); | ||
yield new Pattern('illuminati'); | ||
yield new Pattern('aanstalten'); | ||
yield new Pattern('hurken'); | ||
yield new Pattern('lurven'); | ||
yield new Pattern('luren'); | ||
} | ||
|
||
/** | ||
* @return Pattern[] | ||
*/ | ||
public static function getPlural(): iterable | ||
{ | ||
yield from self::getDefault(); | ||
|
||
// http://nl.wikipedia.org/wiki/Singulare_tantum | ||
yield new Pattern('letterkunde'); | ||
yield new Pattern('muziek'); | ||
yield new Pattern('heelal'); | ||
yield new Pattern('vastgoed'); | ||
yield new Pattern('have'); | ||
yield new Pattern('nageslacht'); | ||
} | ||
|
||
/** | ||
* @return Pattern[] | ||
*/ | ||
private static function getDefault(): iterable | ||
{ | ||
yield new Pattern('twitter'); | ||
This comment has been minimized.
Sorry, something went wrong.
noud
Author
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
tests/Doctrine/Tests/Inflector/Rules/Dutch/DutchFunctionalTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Tests\Inflector\Rules\Dutch; | ||
|
||
use Doctrine\Inflector\Inflector; | ||
use Doctrine\Inflector\InflectorFactory; | ||
use Doctrine\Inflector\Language; | ||
use Doctrine\Tests\Inflector\Rules\LanguageFunctionalTest; | ||
|
||
class DutchFunctionalTest extends LanguageFunctionalTest | ||
{ | ||
/** | ||
* @return string[][] | ||
*/ | ||
public function dataSampleWords(): array | ||
{ | ||
return [ | ||
['aanbod', 'aanbiedingen'], | ||
['adres', 'adressen'], | ||
['beleg', 'belegeringen'], | ||
['dank', 'dankbetuigingen'], | ||
['ei', 'eieren'], | ||
['epos', 'epen'], | ||
['gedrag', 'gedragingen'], | ||
['gelid', 'gelederen'], | ||
['genius', 'geniën'], | ||
['genot', 'genietingen'], | ||
['industrie', 'industrieën'], | ||
['kalf', 'kalveren'], | ||
['koe', 'koeien'], | ||
['lam', 'lammeren'], | ||
['leerrede', 'leerredenen'], | ||
['lende', 'lendenen'], | ||
['lid', 'leden'], | ||
['lof', 'lofbetuigingen'], | ||
['matrices', 'matrix'], | ||
['mogelijkheid', 'mogelijkheden'], | ||
['olie', 'oliën'], | ||
['qaestrices', 'quaestrix'], | ||
['rij', 'rijen'], | ||
['schip', 'schepen'], | ||
['smid', 'smeden'], | ||
['stad', 'steden'], | ||
['twitter', 'twitter'], | ||
['vlo', 'vlooien'], | ||
['weerman', 'weermannen'], | ||
]; | ||
} | ||
|
||
protected function createInflector(): Inflector | ||
{ | ||
return InflectorFactory::createForLanguage(Language::DUTCH)->build(); | ||
} | ||
} |
euu and now, maybe, we lost the age of country existing in the 'array plain straight sorted' order?