Пример #1
0
if (morpher_inflect("кошка", "vin mn") != "кошек") {
    echo "Test 'koshki' (vin mn) failed.\n";
}
if (morpher_inflect("кошка", "tvor mn") != "кошками") {
    echo "Test 'koshki' (tvor mn) failed.\n";
}
if (morpher_inflect("кошка", "predl mn") != "кошках") {
    echo "Test 'koshki' (predl mn) failed.\n";
}
if (morpher_inflect("кошка", "predl-o mn") != "о кошках") {
    echo "Test 'koshki' (predl-o mn) failed.\n";
}
if (morpher_inflect("кошка", "gde mn") != "в кошках") {
    echo "Test 'koshki' (gde mn) failed.\n";
}
if (morpher_inflect("ножницы", "im mn") != "#ERROR: Parameter 1 'text' is plural.") {
    echo "Test 'nozhnicy' failed.\n";
}
if (morpher_spell(123.56, "руб") != "Сто двадцать три руб 56 коп") {
    echo "123 rub failed\n";
}
if (morpher_spell(123.56, "руб", "И") != "Сто двадцать три руб 56 коп") {
    echo "123 rub (im rus) failed\n";
}
if (morpher_spell(123.56, "руб", "Р") != "Ста двадцати трёх руб 56 коп") {
    echo "123 rub (rod rus) failed\n";
}
if (morpher_spell(123.56, "руб", "Д") != "Ста двадцати трём руб 56 коп") {
    echo "123 rub (dat rus) failed\n";
}
if (morpher_spell(123.56, "руб", "В") != "Сто двадцать три руб 56 коп") {
Пример #2
0
<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description  
 * @package Codeine
 * @version 8.x
 */
setFn('Convert', function ($Call) {
    if (preg_match_all('/\\"(.*)\\"/Ssu', $Call['Value'], $Saved)) {
        foreach ($Saved[0] as $IX => $Match) {
            $Call['Value'] = str_replace($Match, '$' . $IX . '$', $Call['Value']);
        }
    }
    $Value = morpher_inflect($Call['Value'], $Call['Morpher']['Cases mapping'][$Call['Case']]);
    if (empty($Value) or $Value[0] == '#') {
        switch ($Call['Case']) {
            case 'Praepositionalis':
                $Call['Value'] = 'о ' . $Call['Value'];
                break;
        }
        if (preg_match_all('/\\"(.*)\\"/Ssu', $Call['Value'], $Pockets)) {
            foreach ($Pockets[0] as $IX => $Match) {
                $Call['Value'] = str_replace($Match, '$' . $IX . '$', $Call['Value']);
            }
        }
    } else {
        $Call['Value'] = $Value;
    }
    if (preg_match_all('/\\$(.*)\\$/Ssu', $Call['Value'], $Restore)) {
        foreach ($Restore[0] as $IX => $Match) {