MediaWiki  REL1_22
LanguageTyv.php
Go to the documentation of this file.
00001 <?php
00031 class LanguageTyv extends Language {
00040     function convertGrammar( $word, $case ) {
00041         global $wgGrammarForms;
00042         if ( isset( $wgGrammarForms['tyv'][$case][$word] ) ) {
00043             return $wgGrammarForms['tyv'][$case][$word];
00044         }
00045 
00046         // Set up some constants...
00047         $allVowels = array( "е", "и", "э", "ө", "ү", "а", "ё", "о", "у", "ы", "ю", "я", "a", "e", "i", "o", "ö", "u", "ü", "y" );
00048         $frontVowels = array( "е", "и", "э", "ө", "ү", "e", "i", "ö", "ü" );
00049         $backVowels = array( "а", "ё", "о", "у", "ы", "ю", "я", "a", "o", "u", "y" );
00050         $unroundFrontVowels = array( "е", "и", "э", "e", "i" );
00051         $roundFrontVowels = array( "ө", "ү", "ö", "ü" );
00052         $unroundBackVowels = array( "а", "ы", "я", "a", "y" );
00053         $roundBackVowels = array( "ё", "о", "у", "ю", "o", "u" );
00054         //$voicedPhonemes = array( "д", "б", "з", "ж", "г", "d", "b", "z", "g" );
00055         $unvoicedPhonemes = array( "т", "п", "с", "ш", "к", "ч", "х", "t", "p", "s", "k", "x" );
00056         $directiveUnvoicedStems = array( "т", "п", "с", "ш", "к", "ч", "х", "л", "м", "н", "ң", "t", "p", "s", "k", "x", "l", "m", "n", "ŋ" );
00057         $directiveVoicedStems = array( "д", "б", "з", "ж", "г", "р", "й", "d", "b", "z", "g", "r", "j" );
00058 
00059         //$allSonants = array("л", "м", "н", "ң", "р", "й");
00060         //$allNasals = array("м", "н", "ң");
00061 
00062         //Put the word in a form we can play with since we're using UTF-8
00063         preg_match_all( '/./us', $word, $ar );
00064 
00065         $wordEnding = $ar[0][count( $ar[0] ) - 1]; // Here's the last letter in the word
00066         $wordReversed = array_reverse( $ar[0] ); // Here's an array with the order of the letters in the word reversed so we can find a match quicker *shrug*
00067 
00068         // Find the last vowel in the word
00069         $wordLastVowel = NULL;
00070         foreach ( $wordReversed as $xvalue ) {
00071             foreach ( $allVowels as $yvalue ) {
00072                 if ( strcmp( $xvalue, $yvalue ) == 0 ) {
00073                     $wordLastVowel = $xvalue;
00074                     break;
00075                 } else {
00076                     continue;
00077                 }
00078             }
00079             if ( $wordLastVowel !== NULL ) {
00080                 break;
00081             } else {
00082                 continue;
00083             }
00084         }
00085 
00086         // Now convert the word
00087         switch ( $case ) {
00088             case "genitive":
00089                 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
00090                     if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
00091                         $word = implode( "", $ar[0] ) . "түң";
00092                     } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
00093                         $word = implode( "", $ar[0] ) . "тиң";
00094                     } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
00095                         $word = implode( "", $ar[0] ) . "туң";
00096                     } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
00097                         $word = implode( "", $ar[0] ) . "тың";
00098                     } else {
00099                     }
00100                 } elseif ( $wordEnding === "л" || $wordEnding === "l" ) {
00101                     if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
00102                         $word = implode( "", $ar[0] ) . "дүң";
00103                     } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
00104                         $word = implode( "", $ar[0] ) . "диң";
00105                     } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
00106                         $word = implode( "", $ar[0] ) . "дуң";
00107                     } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
00108                         $word = implode( "", $ar[0] ) . "дың";
00109                     } else {
00110                     }
00111                 } else {
00112                     if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
00113                         $word = implode( "", $ar[0] ) . "нүң";
00114                     } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
00115                         $word = implode( "", $ar[0] ) . "ниң";
00116                     } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
00117                         $word = implode( "", $ar[0] ) . "нуң";
00118                     } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
00119                         $word = implode( "", $ar[0] ) . "ның";
00120                     } else {
00121                     }
00122                 }
00123                 break;
00124             case "dative":
00125                 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
00126                     if ( in_array( $wordLastVowel, $frontVowels ) ) {
00127                         $word = implode( "", $ar[0] ) . "ке";
00128                     } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00129                         $word = implode( "", $ar[0] ) . "ка";
00130                     } else {
00131                     }
00132                 } else {
00133                     if ( in_array( $wordLastVowel, $frontVowels ) ) {
00134                         $word = implode( "", $ar[0] ) . "ге";
00135                     } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00136                         $word = implode( "", $ar[0] ) . "га";
00137                     } else {
00138                     }
00139                 }
00140                 break;
00141             case "accusative":
00142                 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
00143                     if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
00144                         $word = implode( "", $ar[0] ) . "тү";
00145                     } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
00146                         $word = implode( "", $ar[0] ) . "ти";
00147                     } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
00148                         $word = implode( "", $ar[0] ) . "ту";
00149                     } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
00150                         $word = implode( "", $ar[0] ) . "ты";
00151                     } else {
00152                     }
00153                 } elseif ( $wordEnding === "л" || $wordEnding === "l" ) {
00154                     if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
00155                         $word = implode( "", $ar[0] ) . "дү";
00156                     } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
00157                         $word = implode( "", $ar[0] ) . "ди";
00158                     } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
00159                         $word = implode( "", $ar[0] ) . "ду";
00160                     } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
00161                         $word = implode( "", $ar[0] ) . "ды";
00162                     } else {
00163                     }
00164                 } else {
00165                     if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
00166                         $word = implode( "", $ar[0] ) . "нү";
00167                     } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
00168                         $word = implode( "", $ar[0] ) . "ни";
00169                     } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
00170                         $word = implode( "", $ar[0] ) . "ну";
00171                     } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
00172                         $word = implode( "", $ar[0] ) . "ны";
00173                     } else {
00174                     }
00175                 }
00176                 break;
00177             case "locative":
00178                 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
00179                     if ( in_array( $wordLastVowel, $frontVowels ) ) {
00180                         $word = implode( "", $ar[0] ) . "те";
00181                     } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00182                         $word = implode( "", $ar[0] ) . "та";
00183                     } else {
00184                     }
00185                 } else {
00186                     if ( in_array( $wordLastVowel, $frontVowels ) ) {
00187                         $word = implode( "", $ar[0] ) . "де";
00188                     } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00189                         $word = implode( "", $ar[0] ) . "да";
00190                     } else {
00191                     }
00192                 }
00193                 break;
00194             case "ablative":
00195                 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
00196                     if ( in_array( $wordLastVowel, $frontVowels ) ) {
00197                         $word = implode( "", $ar[0] ) . "тен";
00198                     } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00199                         $word = implode( "", $ar[0] ) . "тан";
00200                     } else {
00201                     }
00202                 } else {
00203                     if ( in_array( $wordLastVowel, $frontVowels ) ) {
00204                         $word = implode( "", $ar[0] ) . "ден";
00205                     } elseif ( in_array( $wordLastVowel, $backVowels ) ) {
00206                         $word = implode( "", $ar[0] ) . "дан";
00207                     } else {
00208                     }
00209                 }
00210                 break;
00211             case "directive1":
00212                 if ( in_array( $wordEnding, $directiveVoicedStems ) ) {
00213                     $word = implode( "", $ar[0] ) . "же";
00214                 } elseif ( in_array( $wordEnding, $directiveUnvoicedStems ) ) {
00215                     $word = implode( "", $ar[0] ) . "че";
00216                 } else {
00217                 }
00218                 break;
00219             case "directive2":
00220                 if ( in_array( $wordEnding, $unvoicedPhonemes ) ) {
00221                     if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
00222                         $word = implode( "", $ar[0] ) . "түве";
00223                     } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
00224                         $word = implode( "", $ar[0] ) . "тиве";
00225                     } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
00226                         $word = implode( "", $ar[0] ) . "туве";
00227                     } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
00228                         $word = implode( "", $ar[0] ) . "тыве";
00229                     } else {
00230                     }
00231                 } else {
00232                     if ( in_array( $wordLastVowel, $roundFrontVowels ) ) {
00233                         $word = implode( "", $ar[0] ) . "дүве";
00234                     } elseif ( in_array( $wordLastVowel, $unroundFrontVowels ) ) {
00235                         $word = implode( "", $ar[0] ) . "диве";
00236                     } elseif ( in_array( $wordLastVowel, $roundBackVowels ) ) {
00237                         $word = implode( "", $ar[0] ) . "дуве";
00238                     } elseif ( in_array( $wordLastVowel, $unroundBackVowels ) ) {
00239                         $word = implode( "", $ar[0] ) . "дыве";
00240                     } else {
00241                     }
00242                 }
00243                 break;
00244             default:
00245                 break;
00246         }
00247         return $word;
00248     }
00249 }