Convert Russian grammar cases from PHP to JSON
authorAmir E. Aharoni <amir.aharoni@mail.huji.ac.il>
Mon, 21 Sep 2015 19:57:08 +0000 (22:57 +0300)
committerAmire80 <amir.aharoni@mail.huji.ac.il>
Mon, 28 Sep 2015 14:24:01 +0000 (14:24 +0000)
commitae78d44091511a7f4f56a4a43c69b31e0188edba
treee0b6a14666b53378b5e93fff05b1775818f5ab04
parent44a296d48917ff620367241c00005b824445686a
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
languages/classes/LanguageRu.php
languages/classes/data/grammar.ru.json [new file with mode: 0644]