wiki.techinc.nl/languages/classes/data/grammar.ru.json
Amir E. Aharoni ae78d44091 Convert Russian grammar cases from PHP to JSON
This is a follow-up to
Ib6a0afa5c3736f8b9b2e121cd752c53ee50fad75

The PHP logic for grammatical cases in Russian was growing.
It was too long and not reusable is JavaScript.

This patch moves all the logic to a JSON file,
indexed by the grammatical case name and then
by regular expressions that match the different
word classes, with the values being the replacements
that should be compatible with common regular expression
replacement functions in modern programming languages.

This patch doesn't introduce any functional changes
and doesn't change any tests.

The next steps, not necessarily in this order, are:
* Make it work also with JavaScript.
* Make JSON grammar data files loadable with ResourceLoader.
* Convert most or all grammar rules for all the languages to JSON.
* Make the data processing loop generic for all languages.
* Convert it also in jquery.i18n (Milkshake).
* Convert the test cases data from code to generic data.
* Move the JSON data to a separate reusable repository.

Change-Id: I0e8e1bfb9d3ec9f841f733356af32dad7d130e94
2015-09-28 14:24:01 +00:00

51 lines
1.5 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"@metadata": {
"authors": [
"Alexander Sigachov (alexander.sigachov at Googgle Mail)",
"Amir E. Aharoni (amir.aharoni@mail.huji.ac.il)"
],
"comment": "These rules don't cover the whole grammar of the language, and are intended only for names of languages and Wikimedia projects."
},
"genitive": {
"(.+)ь$": "$1я",
"(.+)ия$": "$1ии",
"(.+)ка$": "$1ки",
"(.+)ти$": "$1тей",
"(.+)ды$": "$1дов",
"(.+)д$": "$1да",
"(.+)ник$": "$1ника",
"(.+)ные$": "$1ных"
},
"prepositional": {
"(.+)ь$": "$1е",
"(.+)ия$": "$1ии",
"(.+)ка$": "$1ке",
"(.+)ти$": "$1тях",
"(.+)ды$": "$1дах",
"(.+)д$": "$1де",
"(.+)ник$": "$1нике",
"(.+)ные$": "$1ных"
},
"languagegen": {
"@metadata": "язык в родительном падеже: '(с) русского'",
"(.+)кий$": "$1кого",
"иврит$": "иврита",
"идиш$": "идиша",
"(.+)$": "$1"
},
"languageprep": {
"@metadata": "язык в предложном падеже: '(на) русском'",
"(.+)кий$": "$1ком",
"иврит$": "иврите",
"идиш$": "идише",
"(.+)$": "$1"
},
"languageadverb": {
"@metadata": "наречие с названием языка: 'по-русски'",
"(.+)кий$": "по-$1ки",
"иврит$": "на иврите",
"идиш$": "на идише",
"(идо|урду|хинди|эсперанто)$": "на $1",
"(.+)$": "на языке $1"
}
}