示例#1
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);
        }