public static string ResolveD(TxtWord root, string formation, string formationToCheck)
        {
            if (root.IsAbbreviation())
            {
                return(formation + 'd');
            }

            if (Word.LastPhoneme(formationToCheck) >= '0' && Word.LastPhoneme(formationToCheck) <= '9')
            {
                switch (Word.LastPhoneme(formationToCheck))
                {
                case '3':
                case '4':
                case '5':
                    //3->3'tü, 5->5'ti, 4->4'tü
                    return(formation + 't');

                case '0':
                    if (root.GetName().EndsWith("40") || root.GetName().EndsWith("60") ||
                        root.GetName().EndsWith("70"))
                    {
                        //40->40'tı, 60->60'tı, 70->70'ti
                        return(formation + 't');
                    }
                    else
                    {
                        //30->30'du, 50->50'ydi, 80->80'di
                        return(formation + 'd');
                    }

                default:
                    return(formation + 'd');
                }
            }

            if (TurkishLanguage.IsSertSessiz(Word.LastPhoneme(formationToCheck)))
            {
                //yap+DH->yaptı
                return(formation + 't');
            }

            //sar+DH->sardı
            return(formation + 'd');
        }
コード例 #2
0
        public string MakeTransition(TxtWord root, string stem, State startState)
        {
            var rootWord  = root.GetName() == stem || root.GetName() + "'" == stem;
            var formation = stem;
            var i         = 0;

            if (_with == "0")
            {
                return(stem);
            }

            if ((stem.Equals("bu") || stem.Equals("şu") || stem.Equals("o")) && rootWord &&
                _with == "ylA")
            {
                return(stem + "nunla");
            }

            if (_with == "yA")
            {
                if (stem.Equals("ben"))
                {
                    return("bana");
                }

                if (stem.Equals("sen"))
                {
                    return("sana");
                }
            }

            _formationToCheck = stem;
            //---vowelEChangesToIDuringYSuffixation---
            //de->d(i)yor, ye->y(i)yor
            if (rootWord && WithFirstChar() == 'y' && root.VowelEChangesToIDuringYSuffixation() &&
                (_with[1] != 'H' || root.GetName() == "ye"))
            {
                formation         = stem.Substring(0, stem.Length - 1) + 'i';
                _formationToCheck = formation;
            }
            else
            {
                //---lastIdropsDuringPassiveSuffixation---
                // yoğur->yoğrul, ayır->ayrıl, buyur->buyrul, çağır->çağrıl, çevir->çevril, devir->devril,
                // kavur->kavrul, kayır->kayrıl, kıvır->kıvrıl, savur->savrul, sıyır->sıyrıl, yoğur->yoğrul
                if (rootWord && (_with == "Hl" || _with == "Hn") && root.LastIdropsDuringPassiveSuffixation())
                {
                    formation         = stem.Substring(0, stem.Length - 2) + stem[stem.Length - 1];
                    _formationToCheck = stem;
                }
                else
                {
                    //---showsSuRegularities---
                    //karasu->karasuyu, özsu->özsuyu, ağırsu->ağırsuyu, akarsu->akarsuyu, bengisu->bengisuyu
                    if (rootWord && root.ShowsSuRegularities() && StartWithVowelOrConsonantDrops() &&
                        !_with.StartsWith("y"))
                    {
                        formation         = stem + 'y';
                        _formationToCheck = formation;
                    }
                    else
                    {
                        if (rootWord && root.DuplicatesDuringSuffixation() &&
                            !startState.GetName().StartsWith("VerbalRoot") &&
                            TurkishLanguage.IsConsonantDrop(_with[0]))
                        {
                            //---duplicatesDuringSuffixation---
                            if (SoftenDuringSuffixation(root))
                            {
                                //--extra softenDuringSuffixation
                                switch (Word.LastPhoneme(stem))
                                {
                                case 'p':
                                    //tıp->tıbbı
                                    formation = stem.Substring(0, stem.Length - 1) + "bb";
                                    break;

                                case 't':
                                    //cet->ceddi, met->meddi, ret->reddi, serhat->serhaddi, zıt->zıddı, şet->şeddi
                                    formation = stem.Substring(0, stem.Length - 1) + "dd";
                                    break;
                                }
                            }
                            else
                            {
                                //cer->cerri, emrihak->emrihakkı, fek->fekki, fen->fenni, had->haddi, hat->hattı,
                                // haz->hazzı, his->hissi
                                formation = stem + stem[stem.Length - 1];
                            }

                            _formationToCheck = formation;
                        }
                        else
                        {
                            if (rootWord && root.LastIdropsDuringSuffixation() &&
                                !startState.GetName().StartsWith("VerbalRoot") &&
                                !startState.GetName().StartsWith("ProperRoot") && StartWithVowelOrConsonantDrops())
                            {
                                //---lastIdropsDuringSuffixation---
                                if (SoftenDuringSuffixation(root))
                                {
                                    //---softenDuringSuffixation---
                                    switch (Word.LastPhoneme(stem))
                                    {
                                    case 'p':
                                        //hizip->hizbi, kayıp->kaybı, kayıt->kaydı, kutup->kutbu
                                        formation = stem.Substring(0, stem.Length - 2) + 'b';
                                        break;

                                    case 't':
                                        //akit->akdi, ahit->ahdi, lahit->lahdi, nakit->nakdi, vecit->vecdi
                                        formation = stem.Substring(0, stem.Length - 2) + 'd';
                                        break;

                                    case 'ç':
                                        //eviç->evci, nesiç->nesci
                                        formation = stem.Substring(0, stem.Length - 2) + 'c';
                                        break;
                                    }
                                }
                                else
                                {
                                    //sarıağız->sarıağzı, zehir->zehri, zikir->zikri, nutuk->nutku, omuz->omzu, ömür->ömrü
                                    //lütuf->lütfu, metin->metni, kavim->kavmi, kasıt->kastı
                                    formation = stem.Substring(0, stem.Length - 2) + stem[stem.Length - 1];
                                }

                                _formationToCheck = stem;
                            }
                            else
                            {
                                switch (Word.LastPhoneme(stem))
                                {
                                //---nounSoftenDuringSuffixation or verbSoftenDuringSuffixation
                                case 'p':
                                    //adap->adabı, amip->amibi, azap->azabı, gazap->gazabı
                                    if (StartWithVowelOrConsonantDrops() && rootWord &&
                                        SoftenDuringSuffixation(root))
                                    {
                                        formation = stem.Substring(0, stem.Length - 1) + 'b';
                                    }

                                    break;

                                case 't':
                                    //abat->abadı, adet->adedi, akort->akordu, armut->armudu
                                    //affet->affedi, yoket->yokedi, sabret->sabredi, rakset->raksedi
                                    if (StartWithVowelOrConsonantDrops() && rootWord &&
                                        SoftenDuringSuffixation(root))
                                    {
                                        formation = stem.Substring(0, stem.Length - 1) + 'd';
                                    }

                                    break;

                                case 'ç':
                                    //ağaç->ağacı, almaç->almacı, akaç->akacı, avuç->avucu
                                    if (StartWithVowelOrConsonantDrops() && rootWord &&
                                        SoftenDuringSuffixation(root))
                                    {
                                        formation = stem.Substring(0, stem.Length - 1) + 'c';
                                    }

                                    break;

                                case 'g':
                                    //arkeolog->arkeoloğu, filolog->filoloğu, minerolog->mineroloğu
                                    if (StartWithVowelOrConsonantDrops() && rootWord &&
                                        SoftenDuringSuffixation(root))
                                    {
                                        formation = stem.Substring(0, stem.Length - 1) + 'ğ';
                                    }

                                    break;

                                case 'k':
                                    //ahenk->ahengi, künk->küngü, renk->rengi, pelesenk->pelesengi
                                    if (StartWithVowelOrConsonantDrops() && rootWord &&
                                        root.EndingKChangesIntoG() && !root.IsProperNoun())
                                    {
                                        formation = stem.Substring(0, stem.Length - 1) + 'g';
                                    }
                                    else
                                    {
                                        //ablak->ablağı, küllük->küllüğü, kitaplık->kitaplığı, evcilik->evciliği
                                        if (StartWithVowelOrConsonantDrops() &&
                                            (!rootWord ||
                                             (SoftenDuringSuffixation(root) &&
                                              (!root.IsProperNoun() ||
                                               !startState.ToString().Equals("ProperRoot")))))
                                        {
                                            formation = stem.Substring(0, stem.Length - 1) + 'ğ';
                                        }
                                    }

                                    break;
                                }

                                _formationToCheck = formation;
                            }
                        }
                    }
                }
            }

            if (TurkishLanguage.IsConsonantDrop(WithFirstChar()) &&
                !TurkishLanguage.IsVowel(stem[stem.Length - 1]) &&
                (root.IsNumeral() || root.IsReal() || root.IsFraction() || root.IsTime() || root.IsDate() ||
                 root.IsPercent() || root.IsRange()) && (root.GetName().EndsWith("1") || root.GetName().EndsWith("3") ||
                                                         root.GetName().EndsWith("4") || root.GetName().EndsWith("5") ||
                                                         root.GetName().EndsWith("8") || root.GetName().EndsWith("9") ||
                                                         root.GetName().EndsWith("10") ||
                                                         root.GetName().EndsWith("30") ||
                                                         root.GetName().EndsWith("40") ||
                                                         root.GetName().EndsWith("60") ||
                                                         root.GetName().EndsWith("70") ||
                                                         root.GetName().EndsWith("80") ||
                                                         root.GetName().EndsWith("90") ||
                                                         root.GetName().EndsWith("00")))
            {
                if (_with[0] == '\'')
                {
                    formation += '\'';
                    i          = 2;
                }
                else
                {
                    i = 1;
                }
            }
            else
            {
                if ((TurkishLanguage.IsConsonantDrop(WithFirstChar()) &&
                     TurkishLanguage.IsConsonant(Word.LastPhoneme(stem))) ||
                    (rootWord && root.ConsonantSMayInsertedDuringPossesiveSuffixation()))
                {
                    if (_with[0] == '\'')
                    {
                        formation += '\'';
                        if (root.IsAbbreviation())
                        {
                            i = 1;
                        }
                        else
                        {
                            i = 2;
                        }
                    }
                    else
                    {
                        i = 1;
                    }
                }
            }

            for (; i < _with.Length; i++)
            {
                switch (_with[i])
                {
                case 'D':
                    formation = MorphotacticEngine.ResolveD(root, formation, _formationToCheck);
                    break;

                case 'A':
                    formation = MorphotacticEngine.ResolveA(root, formation, rootWord, _formationToCheck);
                    break;

                case 'H':
                    if (_with[0] != '\'')
                    {
                        formation = MorphotacticEngine.ResolveH(root, formation, i == 0, _with.StartsWith("Hyor"), rootWord, _formationToCheck);
                    }
                    else
                    {
                        formation = MorphotacticEngine.ResolveH(root, formation, i == 1, false, rootWord, _formationToCheck);
                    }

                    break;

                case 'C':
                    formation = MorphotacticEngine.ResolveC(formation, _formationToCheck);
                    break;

                case 'S':
                    formation = MorphotacticEngine.ResolveS(formation);
                    break;

                case 'Ş':
                    formation = MorphotacticEngine.ResolveSh(formation);
                    break;

                default:
                    if (i == _with.Length - 1 && _with[i] == 's')
                    {
                        formation += 'ş';
                    }
                    else
                    {
                        formation += _with[i];
                    }

                    break;
                }

                _formationToCheck = formation;
            }

            return(formation);
        }
        public static string ResolveA(TxtWord root, string formation, bool rootWord, string formationToCheck)
        {
            if (root.IsAbbreviation())
            {
                return(formation + 'e');
            }

            if (Word.LastVowel(formationToCheck) >= '0' && Word.LastVowel(formationToCheck) <= '9')
            {
                switch (Word.LastVowel(formationToCheck))
                {
                case '6':
                case '9':
                    //6'ya, 9'a
                    return(formation + 'a');

                case '0':
                    if (root.GetName().EndsWith("10") || root.GetName().EndsWith("30") ||
                        root.GetName().EndsWith("40") || root.GetName().EndsWith("60") ||
                        root.GetName().EndsWith("90"))
                    {
                        //10'a, 30'a, 40'a, 60'a, 90'a
                        return(formation + 'a');
                    }
                    else
                    {
                        //20'ye, 50'ye, 80'e, 70'e
                        return(formation + 'e');
                    }

                default:
                    //3'e, 8'e, 4'e, 2'ye
                    return(formation + 'e');
                }
            }

            if (TurkishLanguage.IsBackVowel(Word.LastVowel(formationToCheck)))
            {
                if (root.NotObeysVowelHarmonyDuringAgglutination() && rootWord)
                {
                    //alkole, anormale, ampule, tümamirali, spirali, sosyali
                    return(formation + 'e');
                }

                //sakala, kabala, eve, kediye
                return(formation + 'a');
            }

            if (TurkishLanguage.IsFrontVowel(Word.LastVowel(formationToCheck)))
            {
                if (root.NotObeysVowelHarmonyDuringAgglutination() && rootWord)
                {
                    //sakala, kabala, eve, kediye
                    return(formation + 'a');
                }

                //alkole, anormale, ampule, tümamirali, spirali, sosyali
                return(formation + 'e');
            }

            if (root.IsNumeral() || root.IsFraction() || root.IsReal())
            {
                if (root.GetName().EndsWith("6") || root.GetName().EndsWith("9") || root.GetName().EndsWith("10") ||
                    root.GetName().EndsWith("30") || root.GetName().EndsWith("40") || root.GetName().EndsWith("60") ||
                    root.GetName().EndsWith("90"))
                {
                    return(formation + 'a');
                }

                return(formation + 'e');
            }

            return(formation);
        }
        public static string ResolveH(TxtWord root, string formation, bool beginningOfSuffix,
                                      bool specialCaseTenseSuffix, bool rootWord, string formationToCheck)
        {
            if (root.IsAbbreviation())
            {
                return(formation + 'i');
            }
            if (beginningOfSuffix && TurkishLanguage.IsVowel(Word.LastPhoneme(formationToCheck)) && !specialCaseTenseSuffix)
            {
                return(formation);
            }

            if (specialCaseTenseSuffix)
            {
                //eğer ek Hyor eki ise,
                if (rootWord)
                {
                    if (root.VowelAChangesToIDuringYSuffixation())
                    {
                        if (TurkishLanguage.IsFrontRoundedVowel(Word.BeforeLastVowel(formationToCheck)))
                        {
                            //büyülüyor, bölümlüyor, çözümlüyor, döşüyor
                            return(formation.Substring(0, formation.Length - 1) + 'ü');
                        }

                        if (TurkishLanguage.IsFrontUnroundedVowel(Word.BeforeLastVowel(formationToCheck)))
                        {
                            //adresliyor, alevliyor, ateşliyor, bekliyor
                            return(formation.Substring(0, formation.Length - 1) + 'i');
                        }

                        if (TurkishLanguage.IsBackRoundedVowel(Word.BeforeLastVowel(formationToCheck)))
                        {
                            //buğuluyor, bulguluyor, çamurluyor, aforozluyor
                            return(formation.Substring(0, formation.Length - 1) + 'u');
                        }

                        if (TurkishLanguage.IsBackUnroundedVowel(Word.BeforeLastVowel(formationToCheck)))
                        {
                            //açıklıyor, çalkalıyor, gazlıyor, gıcırdıyor
                            return(formation.Substring(0, formation.Length - 1) + 'ı');
                        }
                    }
                }

                if (TurkishLanguage.IsVowel(Word.LastPhoneme(formationToCheck)))
                {
                    if (TurkishLanguage.IsFrontRoundedVowel(Word.BeforeLastVowel(formationToCheck)))
                    {
                        return(formation.Substring(0, formation.Length - 1) + 'ü');
                    }

                    if (TurkishLanguage.IsFrontUnroundedVowel(Word.BeforeLastVowel(formationToCheck)))
                    {
                        return(formation.Substring(0, formation.Length - 1) + 'i');
                    }

                    if (TurkishLanguage.IsBackRoundedVowel(Word.BeforeLastVowel(formationToCheck)))
                    {
                        return(formation.Substring(0, formation.Length - 1) + 'u');
                    }

                    if (TurkishLanguage.IsBackUnroundedVowel(Word.BeforeLastVowel(formationToCheck)))
                    {
                        return(formation.Substring(0, formation.Length - 1) + 'ı');
                    }
                }
            }

            if (TurkishLanguage.IsFrontRoundedVowel(Word.LastVowel(formationToCheck)) ||
                (TurkishLanguage.IsBackRoundedVowel(Word.LastVowel(formationToCheck)) &&
                 root.NotObeysVowelHarmonyDuringAgglutination()))
            {
                return(formation + 'ü');
            }

            if (TurkishLanguage.IsFrontUnroundedVowel(Word.LastVowel(formationToCheck)) ||
                (Word.LastVowel(formationToCheck) == 'a' && root.NotObeysVowelHarmonyDuringAgglutination()))
            {
                return(formation + 'i');
            }

            if (TurkishLanguage.IsBackRoundedVowel(Word.LastVowel(formationToCheck)))
            {
                return(formation + 'u');
            }

            if (TurkishLanguage.IsBackUnroundedVowel(Word.LastVowel(formationToCheck)))
            {
                return(formation + 'ı');
            }

            if (root.IsNumeral() || root.IsFraction() || root.IsReal())
            {
                if (root.GetName().EndsWith("6") || root.GetName().EndsWith("40") || root.GetName().EndsWith("60") ||
                    root.GetName().EndsWith("90"))
                {
                    //6'yı, 40'ı, 60'ı
                    return(formation + 'ı');
                }

                if (root.GetName().EndsWith("3") || root.GetName().EndsWith("4") || root.GetName().EndsWith("00"))
                {
                    //3'ü, 4'ü, 100'ü
                    return(formation + 'ü');
                }

                if (root.GetName().EndsWith("9") || root.GetName().EndsWith("10") ||
                    root.GetName().EndsWith("30"))
                {
                    //9'u, 10'u, 30'u
                    return(formation + 'u');
                }

                //2'yi, 5'i, 8'i
                return(formation + 'i');
            }

            return(formation);
        }