0 && strlen($pastStem)>$prefLen && strlen($presStem)>$prefLen) { if (substr($pastStem, 0, $prefLen)==substr($presStem, 0, $prefLen)) { $compound = substr($pastStem, 0, $prefLen); $pastStem = substr($pastStem, $prefLen); $presStem = substr($presStem, $prefLen); } } } $isCompound = (!empty($compound)); if ($passive) { $compound .= Conjugate($pastStem, $presStem, $presStemTrans, 21, $person)." "; if ($isPersScript) { $pastStem = "شد"; $presStem = "شو"; } else { $pastStem = "shod"; $presStem = "shaw"; } $presStemTrans = "shaw"; } define("MB", "^"); // morpheme boundary $VyV = ""; $BEyA = ""; $PresInd1sg = ""; $PresInd2sg = ""; $PresInd3sg = ""; $PresInd1pl = ""; $PresInd2pl = ""; $PresInd3pl = ""; $PresSbj1sg = ""; $PresSbj2sg = ""; $PresSbj3sg = ""; $PresSbj1pl = ""; $PresSbj2pl = ""; $PresSbj3pl = ""; $nPresInd1sg = ""; $nPresInd2sg = ""; $nPresInd3sg = ""; $nPresInd1pl = ""; $nPresInd2pl = ""; $nPresInd3pl = ""; $remImp = ""; $rem1 = ""; $ImperativeSg = ""; $ImperativePl = ""; $nImperativeSg = ""; $nImperativePl = ""; // the tense does not exist for the verb (if true) $Imperfect = false; $Progressive = false; $PerfectSubjunctive = false; $PastPerfect = false; $PresentSubjunctive = false; $Imperative = false; if ($isPersScript) { // Form Depending Stems if ($isSpoken) { if ($isLowerRegister) { switch ($pastStem) { case 'شکست': // shekast if (in_array($tense, array(2, 4)) || $tense>11) $pastStem = 'شکس'; else $pastStem = 'شیکس'; break; case 'شکوند': // shekund if ($tense!=2 && $tense!=4 && $tense<12) { $pastStem = 'شیکوند'; } break; case 'ستاد': // staad // vaay staad => vaa staad if ($compound=='وای' && ($isLowerRegister==1 || $isLowerRegister==3)) { $compound = 'وا'; } if ($isLowerRegister>1) { $pastStem = 'ساد'; // staad => ssaad $presStem = 'س'; // st => ss } break; } } switch ($presStem) { case 'گذار': // gzaar if (!in_array($tense, array(1, 3, 5, 6))) { $presStem = 'ذار'; // zaar $pastStem = 'ذاشت'; // zaasht } // if ($tense==9 || $tense==11) $presStem = 'zār'; break; case 'انداز': // andaakhtan-andaaz if ($tense==9 || $tense==11 || $tense==18 || $tense==20) $presStem = substr($presStem, 2); break; } // if (substr($presStem, 0, 2)=='ا') { // andaakhtan-andaaz // if ($tense==9 || $tense==11 || $tense==18 || $tense==20) $presStem = substr($presStem, 2); // } if ($pastStem=='بود') { // bud if ($variant==0 && $tense==7) { $presStem = "-ا"; if ($person==3) $presStem = '-'; } } } if ($pastStem=='بود') { // bud if ($tense==17) { $presStem = "یست"; } } $prsLen = strlen($presStem); switch (substr($presStem, $prsLen-2)) { // If the last symbol is... case 'ا': // alef case 'آ': // alef with madda // case 'ی': // yeh if (!$isSpoken) { $VyV = 'ی'; } break; case 'و': // vav if ($isSpoken) { if (substr($presStemTrans, -2)!="av") $VyV = 'ی'; } else { if (substr($presStemTrans, -2)!="aw") $VyV = 'ی'; } break; } $sg1 = 'م'; $sg2 = 'ی'; $pl1 = 'یم'; if ($isSpoken) { $sg3 = 'ه'; // -e $pl2 = 'ین'; // -in $pl3 = 'ن'; // -an $ea = 'ه‌'; $e_ast = 'ه'; } else { $pl2 = 'ید'; // -id $pl3 = 'ند'; // -and $sg3 = 'د'; // -ad $ea = 'ه‌ا'; $e_ast = 'ه است'; } $PRSsg1 = $sg1; $PRSsg2 = $sg2; $PRSsg3 = $sg3; $PRSpl1 = $pl1; $PRSpl2 = $pl2; $PRSpl3 = $pl3; $pref_mi ='می‌'; $mi = 'می‌'; $be = 'ب'; $na = 'ن'; $naPRS = 'ن'; $ne = 'ن'; $naHV = 'ن'; if (substr($presStem, 0, 2)=='ا' || substr($presStem, 0, 2)=='آ') {// alef or alef with madda if (substr($presStem, 2, 2)!='ی') { // if begins with alef+yeh do not add yeh $BEyA = 'ی'; // yeh } } switch (substr($pastStem,0,2)) { case 'ا': case 'آ': if (substr($pastStem, 2, 2)!='ی') $na = 'نی'; // if begins with alef+yeh do not add yeh } switch (substr($presStem,0,2)) { case 'ا': case 'آ': if (substr($presStem, 2, 2)!='ی') $naPRS = 'نی'; // if begins with alef+yeh do not add yeh } $s = $presStem; $e_baash = 'ه باش'; $daasht = 'داشت'; $e = 'ه'; $e_bud = 'ه بود'; $daar = 'دار'; $khaah = 'خواه'; // Exceptions if ($pastStem=='بود') { // bud $Progressive = true; // Remove: Present Progressive, Past Progressive $PerfectSubjunctive = true; // Remove Perfect Subjunctive $PastPerfect = true; // Remove Past Perfect $be = ''; if ($tense==7) { $mi = ''; if ($variant==1) { $PRSsg3 = ''; } } elseif ($tense==17) { $mi = ''; $PRSsg3 = ''; } if (!$isSpoken) { if ($variant==0) { $PresInd1sg = '-ام'; $PresInd2sg = '-ای'; $PresInd3sg = 'است'; $PresInd1pl = '-ایم'; $PresInd2pl = '-اید'; $PresInd3pl = '-اند'; } // $PresInd1sg = '-ام، هستم، می‌باشم'; // $PresInd2sg = '-ای، هستی، می‌باشی'; // $PresInd3sg = 'است، هست، می‌باشد'; // $PresInd1pl = '-ایم، هستیم، می‌باشیم'; // $PresInd2pl = '-اید، هستید، می‌باشید'; // $PresInd3pl = '-اند، هستند، می‌باشند'; // $nPresInd1sg = 'نیستم، نمی‌باشم'; // $nPresInd2sg = 'نیستی، نمی‌باشی'; // $nPresInd3sg = 'تیست، نمی‌باشد'; // $nPresInd1pl = 'نیستیم، نمی‌باشیم'; // $nPresInd2pl = 'نیستید، نمی‌باشید'; // $nPresInd3pl = 'نیستند، نمی‌باشند'; } } if ($pastStem=='داشت') { // daasht if (!$isCompound) { $Progressive = true; // Remove: Present Progressive, Past Progressive $PresentSubjunctive = true; // Remove Present Subjunctive $mi = ''; $ne = 'ن'; // na- if no -mi- $ImperativeSg = "داشته باش"; $Imperfect = true; // Remove Imperfect $nImperativeSg = $na.$ImperativeSg; $nImperativePl = $nImperativeSg.$pl2; } else { $be = ''; if ($tense==10 || $tense==19) { $pastStem = $compound.$pastStem; $compound = ''; } } } if ($pastStem=='توانست') { // tavaanest $Progressive = true; // Remove: Present Progressive, Past Progressive $Imperative = true; // Remove Imperative } if ($pastStem=='خواست') { // khaast $Progressive = true; } if ($pastStem=='دانست') { // daanest $Progressive = true; } if ($pastStem=='بایست') { // baayest if (!in_array($tense, array(1, 2, 7, 9, 12, 13, 17, 18)) || $person!=3) { // Remove all persons except for 3rd sg return ""; } if (($tense==7 || $tense==17) && $variant==0) { $mi = ''; $ne = 'ن'; // na- if no -mi- } } if ($isSpoken) { switch ($pastStem) { case 'رفت': // raft $ImperativeSg = 'برو'; $ImperativePl = 'برین'; $nImperativeSg = 'نرو'; // $nImperativePl = 'نرین'; break; // case 'اومد': // umad // $PRSsg3 = 'د'; // -ad // break; case 'نشست': // neshast $ImperativeSg = 'بشین، بنشین'; $ImperativePl = 'بشینین، بنشینین'; $nImperativeSg = 'نشین، ننشین'; $nImperativePl = 'نشینین، ننشینین'; break; case 'شد': // shod $ImperativeSg = 'بشو'; // besho $ImperativePl = 'بشین'; // beshin $nImperativeSg = 'نشو'; // nasho break; // case 'شنید': // shenid // $ImperativeSg = 'بشنو'; // beshno // $nImperativeSg = 'نشنو'; // nashno // break; case 'تونست':// tunest $Progressive = true; // Remove: Present Progressive, Past Progressive $Imperative = true; // Remove Imperative break; case 'داد': // daad $ImperativeSg = 'بده'; // bede $ImperativePl = 'بدین'; // bedin $nImperativeSg = 'نده'; // nade break; case 'گفت': // goft $ImperativeSg = 'بگو'; // begu $ImperativePl = 'بگین'; // begin $nImperativeSg = 'نگو'; // nagu break; case 'دونست':// dunest $Progressive = true; break; case 'ستاد': // staad $be = ''; $ImperativeSg = 'ستا'; $ImperativePl = 'ستین'; $nImperativeSg = 'نستا'; $nImperativePl = 'نستین'; break; case 'ساد': // ssaad $be = ''; $ImperativeSg = 'سا'; $ImperativePl = 'سین'; $nImperativeSg = 'نسا'; $nImperativePl = 'نسین'; break; case 'بایست':// baayest $PRSsg3 = 'د'; // -ad break; } if (substr($presStem, -2)=='ا' || substr($presStem, -2)=='آ') { // umad-aa, khaast-khaa $PRSsg3 = 'د'; // -ad } } if (in_array(trim($compound), array('بر'))) { $noBeInSubjunctive = 1; } } else { // Form Depending Stems if ($isSpoken) { switch ($presStem) { case 'gzār': if (!in_array($tense, array(1, 3, 5, 6))) { $presStem = 'zār'; $pastStem = 'zāsht'; } // if ($tense==9 || $tense==11) $presStem = 'zār'; break; // case 'shenās': //// if (in_array($tense, array(7, 8, 17))) { // $presStem = 'shnās'; //// } // break; // case 'ferest': // if (($tense==11 || $tense==20) && $person==2) // $presStem = 'fres'; //// else //// $presStem = 'frest'; // break; } if (substr($presStem, 0, 1)=='a') { // andaakhtan-andaaz if ($tense==9 || $tense==11 || $tense==18 || $tense==20) $presStem = substr($presStem, 1); } $C = "bcdfghjklmnprstvwxz\'"; // consonants $V = "aeiouā"; // vowels // CeCVC => CCVC : ferest => frest; shekast => shkast; shenav => shnav $presStem = preg_replace("'([$C]+)e([$C]+[$V]+[$C]+)'i", "\\1\\2", $presStem); if ($tense==2 || $tense==4 || $tense>11) { $pastStem = preg_replace("'([$C]+)e([$C]+[$V]+[$C]+)'i", "\\1\\2", $pastStem); } if ($isLowerRegister) { // CeHighCVC => CiHighCVC : shekast => shikast $pastStem = preg_replace("'([$C]+)e([kg]+[$C]*[$V]+[$C]+)'i", "\\1i\\2", $pastStem); } if ($isLowerRegister) { // print ""; // vaay staad => vaa staad if ($compound=='vāy' && $pastStem=='stād' && ($isLowerRegister==1 || $isLowerRegister==3)) { $compound = 'vā'; if ($isLowerRegister==3) { $pastStem = str_replace('st', 'ss', $pastStem); $presStem = str_replace('st', 'ss', $presStem); } } else { $pastStem = str_replace('st', 'ss', $pastStem); $presStem = str_replace('st', 'ss', $presStem); if (substr($pastStem, -3)=='ast') { // shikast => shikass $pastStem = substr($pastStem, 0, -1)."s"; } } } if ($isLowerRegister>0 || ($tense==11 || $tense==20) && $person==2) { if (substr($presStem, -3)=='est') { // frest => fres $presStem = substr($presStem, 0, -1); } } if ($presStem=='bāsh') { if ($variant==0 && $tense==7) { $presStem = "-"; } } } return $presStem; if ($presStem=='bāsh') { if ($tense==17) { $presStem = "ist"; } } $prsLen = strlen($presStem); if (substr($presStem, $prsLen-4)=="enaw") { $presStem2 = substr($presStem, 0, $prsLen-4)."nav"; $s = $presStem2; } else { switch (substr($presStem, $prsLen-1)) { case '': case 'u': $VyV = 'y'; break; case 'w': $presStem = substr($presStem, 0, $prsLen-1)."v"; break; default: // if (substr($presStem, $prsLen-2)=='ā') $aya = 'y'; } $s = $presStem; } $mi = "mi"; if (substr($s,0,2)=='ā' || substr($s,0,3)=='yā' || (substr($s,0,1)=='o') && $isSpoken) //substr($s,0,1)=='a' || $be = 'bi'; else $be = 'be'; switch (substr($pastStem,0,1)) { case 'a': if ($isSpoken) { $na = 'na'; break; } case '': // aa case 'i': case 'u': case 'e': case 'o': $na = 'nay'; break; default: $na = 'na'; } switch (substr($presStem,0,1)) { case 'a': case '': // aa case 'i': case 'u': case 'e': case 'o': $naPRS = 'nay'; break; default: $naPRS = 'na'; } $ne = 'ne'; $naHV = 'na'; $pref_mi = 'mi'; $sg1 = 'am'; $sg2 = 'i'; $pl1 = 'im'; if ($isSpoken) { if (strpos(substr($presStem, 1), 'o')!==false && $pastStem!='forukht') { $be = 'bo'; } // double d // if (substr($pastStem, 0, 1)=='d') { // $mi .= 'd'; // $pref_mi .= 'd'; // $be .= 'd'; // } $sg3 = 'e'; $pl2 = 'in'; $pl3 = 'an'; $e_ast = 'e'; } else { $sg3 = 'ad'; $pl2 = 'id'; $pl3 = 'and'; $e_ast = 'e ast'; } $PRSsg1 = $sg1; $PRSsg2 = $sg2; $PRSsg3 = $sg3; $PRSpl1 = $pl1; $PRSpl2 = $pl2; $PRSpl3 = $pl3; $e_baash = 'e bāsh'; $daasht = 'dāsht'; $e = 'e'; $ea = 'e'; $e_bud = 'e bud'; $daar = 'dār'; $khaah = 'khāh'; // Exceptions if ($pastStem=='bud') { $Progressive = true; // Remove: Present Progressive, Past Progressive $PerfectSubjunctive = true; // Remove Perfect Subjunctive $PastPerfect = true; // Remove Past Perfect $be = ''; if ($tense==7) { $mi = ''; if ($variant==1) { $PRSsg3 = ''; } } elseif ($tense==17) { $ne = 'n'; $mi = ''; $PRSsg3 = ''; } if (!$isSpoken) { if ($variant==0) { $PresInd1sg = '-am'; $PresInd2sg = '-i'; $PresInd3sg = 'ast'; $PresInd1pl = '-im'; $PresInd2pl = '-id'; $PresInd3pl = '-and'; } // $PresInd1sg = '-am, hastam, mibāsham'; // $PresInd2sg = '-i, hasti, mibāshi'; // $PresInd3sg = 'ast, hast, mibāshad'; // $PresInd1pl = '-im, hastim, mibāshim'; // $PresInd2pl = '-id, hastid, mibāshid'; // $PresInd3pl = '-and, hastand, mibāshand'; // $nPresInd1sg = 'nistam, nemibāsham'; // $nPresInd2sg = 'nisti, nemibāshi'; // $nPresInd3sg = 'nist, nemibāshad'; // $nPresInd1pl = 'nistim, nemibāshim'; // $nPresInd2pl = 'nistid, nemibāshid'; // $nPresInd3pl = 'nistand, nemibāshand'; } } if ($pastStem=='dāsht') { if (!$isCompound) { $Progressive = true; // Remove: Present Progressive, Past Progressive $PresentSubjunctive = true; // Remove Present Subjunctive $mi = ""; $ne = 'na'; // if no -mi- $ImperativeSg = "dāshte bāsh"; $Imperfect = true; // Remove Imperfect $nImperativeSg = $na.$ImperativeSg; $nImperativePl = $nImperativeSg.$pl2; } else { $be = ''; if ($tense==10 || $tense==19) { $pastStem = $compound.$pastStem; $compound = ''; } } } if ($pastStem=='tavānest') { $Progressive = true; // Remove: Present Progressive, Past Progressive $Imperative = true; // Remove Imperative } if ($presStem=='khāh') { $Progressive = true; } if ($pastStem=='dānest') { $Progressive = true; // Remove: Present Progressive, Past Progressive } if ($pastStem=='bāyest') { if (!in_array($tense, array(1, 2, 7, 9, 12, 13, 17, 18)) || $person!=3) { // Remove all persons except for 3rd sg return ""; } if (($tense==7 || $tense==17) && $variant==0) { $mi = ''; $ne = 'na'; // na- if no -mi- } } if ($isSpoken) { if ($pastStem=='raft') { $ImperativeSg = 'boro'; $ImperativePl = 'berin'; $nImperativeSg = 'naro'; } elseif (substr($presStem, -2)=='ā') { // umad-aa, khaast-khaa if ($presStem=='khā') { $Progressive = true; } if (in_array($tense, array(7, 8, 9, 11, 17, 18, 20))) { $PRSsg1 = 'm'; $PRSsg2 = 'y'; $PRSsg3 = 'd'; $PRSpl1 = 'ym'; $PRSpl2 = 'yn'; $PRSpl3 = 'n'; $VyV = ''; } } elseif ($pastStem=='doid') { $ea = ''; } elseif ($pastStem=='neshast') { $ImperativeSg = 'beshin, benshin'; $ImperativePl = 'beshinin, benshinin'; $nImperativeSg = 'nashin, nanshin'; $nImperativePl = 'nashinin, nanshinin'; } elseif ($pastStem=='shod') { $ImperativeSg = 'besho'; $ImperativePl = 'beshin'; $nImperativeSg = 'nasho'; } if ($pastStem=='tunest') { $Progressive = true; // Remove: Present Progressive, Past Progressive $Imperative = true; // Remove Imperative } if ($pastStem=='dād') { $ImperativeSg = 'bede'; $ImperativePl = 'bedin'; $nImperativeSg = 'nade'; } if ($pastStem=='goft') { $ImperativeSg = 'begu'; $ImperativePl = 'begin'; $nImperativeSg = 'nagu'; } if ($pastStem=='dunest') { $Progressive = true; // Remove: Present Progressive, Past Progressive } if ($pastStem=='shenid') { $ImperativeSg = 'beshno'; $ImperativePl = 'beshnavin'; $nImperativeSg = 'nashno'; } if ($pastStem=='stād' || $pastStem=='ssād') { $be = ''; if (($tense==11 || $tense==20) && $person==2) { $presStem .= 'ā'; } } if ($pastStem=='bāyest') { $PRSsg3 = 'ad'; } } if (in_array(trim($compound), array('bar'))) { $noBeInSubjunctive = 1; } } $bePrSubj = (!empty($compound) && $noBeInSubjunctive==1) ? '' : $be.$BEyA; switch ($tense) { case 1: // Simple Past switch ($person) { case 1: return $compound.$pastStem.$sg1; case 2: return $compound.$pastStem.$sg2; case 3: return $compound.$pastStem; case 4: return $compound.$pastStem.$pl1; case 5: return $compound.$pastStem.$pl2; case 6: return $compound.$pastStem.$pl3; } break; case 2: // Imperfect if (!$Imperfect) { switch ($person) { case 1: return $compound.DropInitVowel($pref_mi.MB.$pastStem).$sg1; case 2: return $compound.DropInitVowel($pref_mi.MB.$pastStem).$sg2; case 3: return $compound.DropInitVowel($pref_mi.MB.$pastStem); case 4: return $compound.DropInitVowel($pref_mi.MB.$pastStem).$pl1; case 5: return $compound.DropInitVowel($pref_mi.MB.$pastStem).$pl2; case 6: return $compound.DropInitVowel($pref_mi.MB.$pastStem).$pl3; } } break; case 3: // Perfect Subjunctive if (!$PerfectSubjunctive) { switch ($person) { case 1: return $compound.$pastStem.$e_baash.$sg1; case 2: return $compound.$pastStem.$e_baash.$sg2; case 3: return $compound.$pastStem.$e_baash.$sg3; case 4: return $compound.$pastStem.$e_baash.$pl1; case 5: return $compound.$pastStem.$e_baash.$pl2; case 6: return $compound.$pastStem.$e_baash.$pl3; } } break; case 4: // Past Progressive if (!$Progressive) { switch ($person) { case 1: return $daasht.$sg1." ".$compound.DropInitVowel($pref_mi.MB.$pastStem).$sg1; case 2: return $daasht.$sg2." ".$compound.DropInitVowel($pref_mi.MB.$pastStem).$sg2; case 3: return $daasht." ".$compound.DropInitVowel($pref_mi.MB.$pastStem); case 4: return $daasht.$pl1." ".$compound.DropInitVowel($pref_mi.MB.$pastStem).$pl1; case 5: return $daasht.$pl2." ".$compound.DropInitVowel($pref_mi.MB.$pastStem).$pl2; case 6: return $daasht.$pl3." ".$compound.DropInitVowel($pref_mi.MB.$pastStem).$pl3; } } break; case 5: // Present Perfect switch ($person) { case 1: return $compound.$pastStem.$ea.$sg1; case 2: return $compound.$pastStem.$ea.$sg2; case 3: return $compound.$pastStem.$e_ast; case 4: return $compound.$pastStem.$ea.$pl1; case 5: return $compound.$pastStem.$ea.$pl2; case 6: return $compound.$pastStem.$ea.$pl3; } break; case 6: // Past Perfect if (!$PastPerfect) { switch ($person) { case 1: return $compound.$pastStem.$e_bud.$sg1; case 2: return $compound.$pastStem.$e_bud.$sg2; case 3: return $compound.$pastStem.$e_bud; case 4: return $compound.$pastStem.$e_bud.$pl1; case 5: return $compound.$pastStem.$e_bud.$pl2; case 6: return $compound.$pastStem.$e_bud.$pl3; } } break; case 7: // Present Indicative switch ($person) { case 0: return $compound . $mi.$s; // impersonal case 1: return $compound . (!empty($PresInd1sg) ? $PresInd1sg : $mi.$s.$VyV.$PRSsg1); case 2: return $compound . (!empty($PresInd2sg) ? $PresInd2sg : $mi.$s.$VyV.$PRSsg2); case 3: return $compound . (!empty($PresInd3sg) ? $PresInd3sg : $mi.$s.$VyV.$PRSsg3); case 4: return $compound . (!empty($PresInd1pl) ? $PresInd1pl : $mi.$s.$VyV.$PRSpl1); case 5: return $compound . (!empty($PresInd2pl) ? $PresInd2pl : $mi.$s.$VyV.$PRSpl2); case 6: return $compound . (!empty($PresInd3pl) ? $PresInd3pl : $mi.$s.$VyV.$PRSpl3); } break; case 8: // Present Progressive if (!$Progressive) { switch ($person) { case 1: return $daar.$sg1." ".$compound . (!empty($PresInd1sg) ? $PresInd1sg : $pref_mi.$s.$VyV.$PRSsg1); case 2: return $daar.$sg2." ".$compound . (!empty($PresInd2sg) ? $PresInd2sg : $pref_mi.$s.$VyV.$PRSsg2); case 3: return $daar.$sg3." ".$compound . (!empty($PresInd3sg) ? $PresInd3sg : $pref_mi.$s.$VyV.$PRSsg3); case 4: return $daar.$pl1." ".$compound . (!empty($PresInd1pl) ? $PresInd1pl : $pref_mi.$s.$VyV.$PRSpl1); case 5: return $daar.$pl2." ".$compound . (!empty($PresInd2pl) ? $PresInd2pl : $pref_mi.$s.$VyV.$PRSpl2); case 6: return $daar.$pl3." ".$compound . (!empty($PresInd3pl) ? $PresInd3pl : $pref_mi.$s.$VyV.$PRSpl3); } } break; case 9: // Present Subjunctive if (!$PresentSubjunctive) { switch ($person) { case 1: return $compound . (!empty($PresSbj1sg) ? $PresSbj1sg : $bePrSubj.NotAlefMaddaInMiddle($s).$VyV.$PRSsg1); case 2: return $compound . (!empty($PresSbj2sg) ? $PresSbj2sg : $bePrSubj.NotAlefMaddaInMiddle($s).$VyV.$PRSsg2); case 3: return $compound . (!empty($PresSbj3sg) ? $PresSbj3sg : $bePrSubj.NotAlefMaddaInMiddle($s).$VyV.$PRSsg3); case 4: return $compound . (!empty($PresSbj1pl) ? $PresSbj1pl : $bePrSubj.NotAlefMaddaInMiddle($s).$VyV.$PRSpl1); case 5: return $compound . (!empty($PresSbj2pl) ? $PresSbj2pl : $bePrSubj.NotAlefMaddaInMiddle($s).$VyV.$PRSpl2); case 6: return $compound . (!empty($PresSbj3pl) ? $PresSbj3pl : $bePrSubj.NotAlefMaddaInMiddle($s).$VyV.$PRSpl3); } } break; case 10: // Future if (!$isSpoken) { switch ($person) { case 1: return $compound.$khaah.$sg1." ".$pastStem; case 2: return $compound.$khaah.$sg2." ".$pastStem; case 3: return $compound.$khaah.$sg3." ".$pastStem; case 4: return $compound.$khaah.$pl1." ".$pastStem; case 5: return $compound.$khaah.$pl2." ".$pastStem; case 6: return $compound.$khaah.$pl3." ".$pastStem; } } break; case 11: // Imperative if (!$Imperative) { switch ($person) { case 2: if ($ImperativeSg) { return $compound.$ImperativeSg; } else { if ($isPersScript) { return $compound.$be.$BEyA.NotAlefMaddaInMiddle($presStem); } else { $prsLen = strlen($presStem); $out = $compound.$be.MB; if (!empty($presStem2)) { $out .= substr($presStem, 0, $prsLen-4).substr($presStem, $prsLen-3); } elseif (substr($presStem, $prsLen-1)=='v') { $out .= substr($presStem, 0, $prsLen-1).'w'; } else { $out .= $presStem; } if ($isSpoken) { // beraw => berow // if (substr($out, strlen($out)-2)=='aw') { // $out = substr($out, 0, strlen($out)-2).'ow'; // } // // berow => borow // $out = preg_replace("'([^\^]*)be\^([^o]*[o]+.*)'i", "\\1bo\\2", $out); // bedeh => bede if (substr($out, -6)=="be^deh") { $out = substr($out, 0, -1); } } $out = str_replace(MB, "", $out); return $out; } } break; case 5: if ($ImperativePl) { return $compound.$ImperativePl; } elseif ($ImperativeSg) { return $compound.$ImperativeSg.$pl2; } else { if ($isPersScript) { return $compound.$be.$BEyA.NotAlefMaddaInMiddle($presStem).$VyV.$pl2; } else { $out = $compound.$be; if (!empty($presStem2)) { $out .= $presStem2.$pl2; } else $out .= $presStem.$VyV.$PRSpl2; return $out; } } break; } } break; case 12: // Negative Past Simple switch ($person) { case 1: return $compound.NaYuNoAlef(DropInitVowel($na.MB.NotAlefMaddaInMiddle($pastStem),1)).$sg1; case 2: return $compound.NaYuNoAlef(DropInitVowel($na.MB.NotAlefMaddaInMiddle($pastStem),1)).$sg2; case 3: return $compound.NaYuNoAlef(DropInitVowel($na.MB.NotAlefMaddaInMiddle($pastStem),1)); case 4: return $compound.NaYuNoAlef(DropInitVowel($na.MB.NotAlefMaddaInMiddle($pastStem),1)).$pl1; case 5: return $compound.NaYuNoAlef(DropInitVowel($na.MB.NotAlefMaddaInMiddle($pastStem),1)).$pl2; case 6: return $compound.NaYuNoAlef(DropInitVowel($na.MB.NotAlefMaddaInMiddle($pastStem),1)).$pl3; } break; case 13: // Negative Imperfect if (!$Imperfect) { switch ($person) { case 1: return $compound.$ne.DropInitVowel($pref_mi.MB.$pastStem).$sg1; case 2: return $compound.$ne.DropInitVowel($pref_mi.MB.$pastStem).$sg2; case 3: return $compound.$ne.DropInitVowel($pref_mi.MB.$pastStem); case 4: return $compound.$ne.DropInitVowel($pref_mi.MB.$pastStem).$pl1; case 5: return $compound.$ne.DropInitVowel($pref_mi.MB.$pastStem).$pl2; case 6: return $compound.$ne.DropInitVowel($pref_mi.MB.$pastStem).$pl3; } } break; case 14: // Negative Perfect Subjunctive if (!$PerfectSubjunctive) { switch ($person) { case 1: return $compound.NaYuNoAlef(DropInitVowel($na.MB.NotAlefMaddaInMiddle($pastStem),1)).$e_baash.$sg1; case 2: return $compound.NaYuNoAlef(DropInitVowel($na.MB.NotAlefMaddaInMiddle($pastStem),1)).$e_baash.$sg2; case 3: return $compound.NaYuNoAlef(DropInitVowel($na.MB.NotAlefMaddaInMiddle($pastStem),1)).$e_baash.$sg3; case 4: return $compound.NaYuNoAlef(DropInitVowel($na.MB.NotAlefMaddaInMiddle($pastStem),1)).$e_baash.$pl1; case 5: return $compound.NaYuNoAlef(DropInitVowel($na.MB.NotAlefMaddaInMiddle($pastStem),1)).$e_baash.$pl2; case 6: return $compound.NaYuNoAlef(DropInitVowel($na.MB.NotAlefMaddaInMiddle($pastStem),1)).$e_baash.$pl3; } } break; case 15: // Negative Present Perfect switch ($person) { case 1: return $compound.NaYuNoAlef(DropInitVowel($na.MB.NotAlefMaddaInMiddle($pastStem),1)).$ea.$sg1; case 2: return $compound.NaYuNoAlef(DropInitVowel($na.MB.NotAlefMaddaInMiddle($pastStem),1)).$ea.$sg2; case 3: return $compound.NaYuNoAlef(DropInitVowel($na.MB.NotAlefMaddaInMiddle($pastStem),1)).$e_ast; case 4: return $compound.NaYuNoAlef(DropInitVowel($na.MB.NotAlefMaddaInMiddle($pastStem),1)).$ea.$pl1; case 5: return $compound.NaYuNoAlef(DropInitVowel($na.MB.NotAlefMaddaInMiddle($pastStem),1)).$ea.$pl2; case 6: return $compound.NaYuNoAlef(DropInitVowel($na.MB.NotAlefMaddaInMiddle($pastStem),1)).$ea.$pl3; } break; case 16: // Negative Past Perfect if (!$PastPerfect) { switch ($person) { case 1: return $compound.NaYuNoAlef(DropInitVowel($na.MB.NotAlefMaddaInMiddle($pastStem),1)).$e_bud.$sg1; case 2: return $compound.NaYuNoAlef(DropInitVowel($na.MB.NotAlefMaddaInMiddle($pastStem),1)).$e_bud.$sg2; case 3: return $compound.NaYuNoAlef(DropInitVowel($na.MB.NotAlefMaddaInMiddle($pastStem),1)).$e_bud; case 4: return $compound.NaYuNoAlef(DropInitVowel($na.MB.NotAlefMaddaInMiddle($pastStem),1)).$e_bud.$pl1; case 5: return $compound.NaYuNoAlef(DropInitVowel($na.MB.NotAlefMaddaInMiddle($pastStem),1)).$e_bud.$pl2; case 6: return $compound.NaYuNoAlef(DropInitVowel($na.MB.NotAlefMaddaInMiddle($pastStem),1)).$e_bud.$pl3; } } break; case 17: // Negative Present Indicative switch ($person) { case 0: return $compound . $ne.$mi.$s; case 1: return $compound . (!empty($nPresInd1sg) ? $nPresInd1sg : $ne.$mi.$s.$VyV.$PRSsg1); case 2: return $compound . (!empty($nPresInd2sg) ? $nPresInd2sg : $ne.$mi.$s.$VyV.$PRSsg2); case 3: return $compound . (!empty($nPresInd3sg) ? $nPresInd3sg : $ne.$mi.$s.$VyV.$PRSsg3); case 4: return $compound . (!empty($nPresInd1pl) ? $nPresInd1pl : $ne.$mi.$s.$VyV.$PRSpl1); case 5: return $compound . (!empty($nPresInd2pl) ? $nPresInd2pl : $ne.$mi.$s.$VyV.$PRSpl2); case 6: return $compound . (!empty($nPresInd3pl) ? $nPresInd3pl : $ne.$mi.$s.$VyV.$PRSpl3); } break; case 18: // Negative Present Subjunctive if (!$PresentSubjunctive) { switch ($person) { case 1: return $compound . (!empty($nPresSbj1sg) ? $nPresSbj1sg : $naPRS.NotAlefMaddaInMiddle($s).$VyV.$PRSsg1); case 2: return $compound . (!empty($nPresSbj2sg) ? $nPresSbj2sg : $naPRS.NotAlefMaddaInMiddle($s).$VyV.$PRSsg2); case 3: return $compound . (!empty($nPresSbj3sg) ? $nPresSbj3sg : $naPRS.NotAlefMaddaInMiddle($s).$VyV.$PRSsg3); case 4: return $compound . (!empty($nPresSbj1pl) ? $nPresSbj1pl : $naPRS.NotAlefMaddaInMiddle($s).$VyV.$PRSpl1); case 5: return $compound . (!empty($nPresSbj2pl) ? $nPresSbj2pl : $naPRS.NotAlefMaddaInMiddle($s).$VyV.$PRSpl2); case 6: return $compound . (!empty($nPresSbj3pl) ? $nPresSbj3pl : $naPRS.NotAlefMaddaInMiddle($s).$VyV.$PRSpl3); } } break; case 19: // Negative Future switch ($person) { case 1: return $compound.$naHV.$khaah.$sg1." ".$pastStem; case 2: return $compound.$naHV.$khaah.$sg2." ".$pastStem; case 3: return $compound.$naHV.$khaah.$sg3." ".$pastStem; case 4: return $compound.$naHV.$khaah.$pl1." ".$pastStem; case 5: return $compound.$naHV.$khaah.$pl2." ".$pastStem; case 6: return $compound.$naHV.$khaah.$pl3." ".$pastStem; } break; case 20: // Negative Imperative if (!$Imperative) { switch ($person) { case 2: if ($nImperativeSg) { return $compound.$nImperativeSg; } elseif ($isPersScript) { return $compound.$naPRS.NotAlefMaddaInMiddle($presStem); } else { $prsLen = strlen($presStem); $out = $compound.$naPRS; if (!empty($presStem2)) { $out .= substr($presStem, 0, $prsLen-4).substr($presStem, $prsLen-3); } elseif (substr($presStem, $prsLen-1)=='v') { $out .= substr($presStem, 0, $prsLen-1).'w'; } else $out .= $presStem; if ($isSpoken) { // naraw => narow // if (substr($out, strlen($out)-2)=='aw') { // $out = substr($out, 0, strlen($out)-2).'ow'; // } // nadeh => nade if (substr($out, -5)=="nadeh") { $out = substr($out, 0, -1); } } return $out; } break; case 5: if ($nImperativePl) { return $compound.$nImperativePl; } elseif ($isPersScript) { return $compound.$naPRS.NotAlefMaddaInMiddle($presStem).$VyV.$pl2; } else { $out = $compound.$naPRS; if (!empty($presStem2)) $out .= $presStem2.$pl2; else $out .= $presStem.$VyV.$PRSpl2; return $out; } break; } } break; case 21: // Past Participle return $compound.$pastStem.$e; break; } return ""; } function NotAlefMaddaInMiddle($s) { if (substr($s, 0, 2)=='آ') { $s = 'ا'.substr($s, 2); } return $s; } function NaYuNoAlef($s) { global $isSpoken; if ($isSpoken) { $s = str_replace("ی".MB."او", "ی".MB."و", $s); // yeh+^+alef+vav => yeh+^+vav } return str_replace(MB, '', $s); } function DropInitVowel($s, $keepMB=0) { global $isSpoken; if ($isSpoken) { $s = str_replace(MB.'a', MB, $s); } if ($keepMB==0) $s = str_replace(MB, '', $s); return $s; } function neg($tense) { if ($tense<4) return $tense+11; elseif ($tense==4 || $tense==8) return 0; elseif ($tense<8) return $tense+10; elseif ($tense<12) return $tense+9; else return 0; } ?>