示例#1
0
        /**
         * <summary>The softenDuringSuffixation method takes a {@link TxtWord} root as an input. It checks two cases; first case returns
         * true if the given root is nominal or adjective and has one of the flags "IS_SD, IS_B_SD, IS_SDD" and with variable
         * equals o one of the strings "Hm, nDAn, ncA, nDA, yA, yHm, yHz, yH, nH, nA, nHn, H, sH, Hn, HnHz, HmHz".
         * <p/>
         * And the second case returns true if the given root is verb and has the "F_SD" flag, also with variable starts with
         * "Hyor" or equals one of the strings "yHs, yAn, yA, yAcAk, yAsH, yHncA, yHp, yAlH, yArAk, yAdur, yHver, yAgel, yAgor,
         * yAbil, yAyaz, yAkal, yAkoy, yAmA, yHcH, HCH, Hr, Hs, Hn, yHn", yHnHz, Ar, Hl").</summary>
         *
         * <param name="root">{@link TxtWord} input.</param>
         * <returns>true if there is softening during suffixation of the given root, false otherwise.</returns>
         */
        public bool SoftenDuringSuffixation(TxtWord root)
        {
            if ((root.IsNominal() || root.IsAdjective()) && root.NounSoftenDuringSuffixation() &&
                (_with == "Hm" || _with == "nDAn" || _with == "ncA" || _with == "nDA" || _with == "yA" ||
                 _with == "yHm" || _with == "yHz" || _with == "yH" || _with == "nH" ||
                 _with == "nA" || _with == "nHn" || _with == "H" || _with == "sH" || _with == "Hn" ||
                 _with == "HnHz" || _with == "HmHz"))
            {
                return(true);
            }

            if (root.IsVerb() && root.VerbSoftenDuringSuffixation() && (_with.StartsWith("Hyor") || _with == "yHs" ||
                                                                        _with == "yAn" || _with == "yA" ||
                                                                        _with.StartsWith("yAcAk") || _with == "yAsH" ||
                                                                        _with == "yHncA" ||
                                                                        _with == "yHp" || _with == "yAlH" ||
                                                                        _with == "yArAk" || _with == "yAdur" ||
                                                                        _with == "yHver" ||
                                                                        _with == "yAgel" || _with == "yAgor" ||
                                                                        _with == "yAbil" || _with == "yAyaz" ||
                                                                        _with == "yAkal" ||
                                                                        _with == "yAkoy" || _with == "yAmA" ||
                                                                        _with == "yHcH" || _with == "HCH" ||
                                                                        _with.StartsWith("Hr") || _with == "Hs" ||
                                                                        _with == "Hn" || _with == "yHn" ||
                                                                        _with == "yHnHz" ||
                                                                        _with.StartsWith("Ar") || _with == "Hl"))
            {
                return(true);
            }

            return(false);
        }
示例#2
0
        protected string AddSuffix(string suffix, string prefix, TxtWord root, string stem)
        {
            Transition transition;

            transition = new Transition(suffix);
            return(prefix + transition.MakeTransition(root, stem));
        }
示例#3
0
        /**
         * <summary>The makeTransition method takes a {@link TxtWord} root and s {@link string} stem as inputs. If given root is a verb,
         * it makes transition with given root and stem with the verbal root state. If given root is not verb, it makes transition
         * with given root and stem and the nominal root state.</summary>
         *
         * <param name="root">{@link TxtWord} input.</param>
         * <param name="stem">string input.</param>
         * <returns>string type output that has the transition.</returns>
         */
        public string MakeTransition(TxtWord root, string stem)
        {
            if (root.IsVerb())
            {
                return(MakeTransition(root, stem, new State("VerbalRoot", true, false)));
            }

            return(MakeTransition(root, stem, new State("NominalRoot", true, false)));
        }
示例#4
0
 public TurkishPartOfSpeechTranslator(ParseNodeDrawable parseNode, List <string> parentList,
                                      List <string> englishWordList, string prefix, string lastWordForm, TxtWord lastWord)
 {
     this.parseNode       = parseNode;
     this.parentList      = parentList;
     this.englishWordList = englishWordList;
     this.prefix          = prefix;
     this.lastWordForm    = lastWordForm;
     this.lastWord        = lastWord;
 }
        /**
         * <summary>Replace root word of the current parse with the new root word and returns the new word.</summary>
         * <param name="newRoot"> Replaced root word</param>
         * <returns> Root word of the parse will be replaced with the newRoot and the resulting surface form is returned.</returns>
         */
        public string ReplaceRootWord(TxtWord newRoot)
        {
            var result = newRoot.GetName();

            foreach (var aWith in _withList)
            {
                var transition = new Transition(null, aWith, null);
                result = transition.MakeTransition(newRoot, result);
            }
            return(result);
        }
示例#6
0
        public bool TransitionPossible(TxtWord root, State fromState)
        {
            if (root.IsAdjective() && (root.IsNominal() && !root.IsExceptional() || root.IsPronoun()) &&
                _toState.GetName() == "NominalRoot(ADJ)" && _with == "0")
            {
                return(false);
            }

            if (root.IsAdjective() && root.IsNominal() && _with == "^DB+VERB+ZERO+PRES+A3PL" &&
                fromState.GetName() == "AdjectiveRoot")
            {
                return(false);
            }

            if (root.IsAdjective() && root.IsNominal() && _with == "SH" &&
                fromState.GetName() == "AdjectiveRoot")
            {
                return(false);
            }

            if (_with == "ki")
            {
                return(root.TakesRelativeSuffixKi());
            }

            if (_with == "kü")
            {
                return(root.TakesRelativeSuffixKu());
            }

            if (_with == "dHr")
            {
                if (_toState.GetName() == "Adverb")
                {
                    return(true);
                }

                return(root.TakesSuffixDIRAsFactitive());
            }

            if (_with == "Hr" && (_toState.GetName() == "AdjectiveRoot(VERB)" ||
                                  _toState.GetName() == "OtherTense" ||
                                  _toState.GetName() == "OtherTense2"))
            {
                return(root.TakesSuffixIRAsAorist());
            }

            return(true);
        }
 /**
  * <summary>Another constructor of {@link FsmParse} class which takes a {@link TxtWord} root and a {@link State} as inputs.
  * First, initializes root variable with this {@link TxtWord}. It also initializes form with root's name, pos and
  * initialPos with given {@link State}'s POS, creates 4 new {@link ArrayList} suffixList, formList, transitionList
  * and withList and adds given {@link State} to suffixList, form to formList.</summary>
  *
  * <param name="root">      {@link TxtWord} input.</param>
  * <param name="startState">{@link State} input.</param>
  */
 public FsmParse(TxtWord root, State startState)
 {
     this.root        = root;
     this._form       = root.GetName();
     this._pos        = startState.GetPos();
     this._initialPos = startState.GetPos();
     _suffixList      = new List <State> {
         startState
     };
     _formList = new List <string> {
         this._form
     };
     _transitionList = new List <string>();
     _withList       = new List <string>();
 }
        /**
         * <summary>Another constructor of {@link FsmParse} class which takes a {@link Double} number and a {@link State} as inputs.
         * First, it creates a {@link TxtWord} with given number and adds flag to this number as IS_SAYI and initializes root variable with
         * number {@link TxtWord}. It also initializes form with root's name, pos and initialPos with given {@link State}'s POS, creates 4 new
         * {@link ArrayList} suffixList, formList, transitionList and withList and adds given {@link State} to suffixList, form to
         * formList.</summary>
         *
         * <param name="number">    {@link Double} input.</param>
         * <param name="startState">{@link State} input.</param>
         */
        public FsmParse(double number, State startState)
        {
            TxtWord num = new TxtWord("" + number);

            num.AddFlag("IS_SAYI");
            this.root        = num;
            this._form       = root.GetName();
            this._pos        = startState.GetPos();
            this._initialPos = startState.GetPos();
            _suffixList      = new List <State> {
                startState
            };
            _formList = new List <string> {
                this._form
            };
            _transitionList = new List <string>();
            _withList       = new List <string>();
        }
        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');
        }
示例#10
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);
        }
示例#11
0
 public TurkishCDTranslator(ParseNodeDrawable parseNode, List <string> parentList, List <string> englishWordList,
                            string prefix, string lastWordForm, TxtWord lastWord, bool withDigits, TxtDictionary txtDictionary) : base(
         parseNode, parentList, englishWordList, prefix, lastWordForm, lastWord, txtDictionary)
 {
     this.withDigits = withDigits;
 }
示例#12
0
 public TurkishRBTranslator(ParseNodeDrawable parseNode, List <string> parentList, List <string> englishWordList,
                            string prefix, string lastWordForm, TxtWord lastWord) : base(parseNode, parentList, englishWordList, prefix,
                                                                                         lastWordForm, lastWord)
 {
 }
        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);
        }
        protected string AddSuffix(string suffix, string prefix, TxtWord root, string stem, string personalPronoun)
        {
            var transition = new Transition(suffix + PersonalSuffix2(personalPronoun));

            return(prefix + transition.MakeTransition(root, stem));
        }
 public TurkishNNTranslator(ParseNodeDrawable parseNode, List <string> parentList, List <string> englishWordList,
                            string prefix, string lastWordForm, TxtWord lastWord, TxtDictionary txtDictionary) : base(parseNode,
                                                                                                                      parentList, englishWordList, prefix, lastWordForm, lastWord, txtDictionary)
 {
 }
        public new string Translate()
        {
            bool previousWordNoun = false;

            string[] posArray2 =
            {
                "IN", "TO"
            }

            ;
            string[] posArray3 =
            {
                "POS", "PRP$"
            }

            ;
            string[][] wordArray2 =
            {
                new [] {
                    "of", "in", "on", "at", "into", "with", "from", "since", "by", "until", "than"
                },
                new [] {
                    "to"
                }
            }

            ;
            string[][] wordArray3 =
            {
                new string[] {
                },
                new []       {
                    "my", "your", "his", "her", "its", "our", "their"
                }
            }

            ;
            string[][] suffixArray2 =
            {
                new [] {
                    "nHn", "DA", "DA", "DA", "nA", "ylA", "DAn", "DAn", "ylA", "nA", "DAn"
                },
                new [] {
                    "yA"
                }
            }

            ;
            string[][] suffixArray2Prime =
            {
                new [] {
                    "nHn", "nDA", "nDA", "nDA", "nA", "ylA", "nDAn", "nDAn", "ylA", "nA", "nDAn"
                },
                new [] {
                    "nA"
                }
            }

            ;
            string[][] suffixArray3 =
            {
                new [] {
                    "nHn"
                },
                new [] {
                    "Hm", "Hn", "sH", "sH", "sH", "HmHz", "H"
                }
            }

            ;
            if (parentList.Count > 1)
            {
                if (prefix != null)
                {
                    TxtWord prefixWord = (TxtWord)txtDictionary.GetWord(prefix.Trim());
                    if (prefixWord != null && prefixWord.IsNominal())
                    {
                        previousWordNoun = true;
                    }
                }

                Transition transition;
                string     result;
                if (IsLastWordOfNounPhrase(parseNode) || previousWordNoun)
                {
                    transition = new Transition("lArH");
                    string newLastWordForm = transition.MakeTransition(lastWord, lastWordForm);
                    result = TranslateNouns(posArray2, wordArray2, suffixArray2Prime, parentList, englishWordList,
                                            prefix, lastWord, newLastWordForm);
                    if (result != null)
                    {
                        return(result);
                    }
                }
                else
                {
                    transition = new Transition("lAr");
                    string newLastWordForm = transition.MakeTransition(lastWord, lastWordForm);
                    result = TranslateNouns(posArray3, wordArray3, suffixArray3, parentList, englishWordList, prefix,
                                            lastWord, newLastWordForm);
                    if (result != null)
                    {
                        var result2 = TranslateNouns(posArray2, wordArray2, suffixArray2, parentList, englishWordList, "",
                                                     lastWord, result);
                        if (result2 != null)
                        {
                            result = result2;
                        }
                    }
                    else
                    {
                        result = TranslateNouns(posArray2, wordArray2, suffixArray2, parentList, englishWordList,
                                                prefix, lastWord, newLastWordForm);
                    }
                }

                if (result != null)
                {
                    return(result);
                }

                if (IsLastWordOfNounPhrase(parseNode) || previousWordNoun)
                {
                    return(AddSuffix("lArH", prefix, lastWord, lastWordForm));
                }

                return(AddSuffix("lAr", prefix, lastWord, lastWordForm));
            }

            return(AddSuffix("lAr", prefix, lastWord, lastWordForm));
        }
        protected string TranslateNouns(string[] posArray, string[][] wordArray, string[][] suffixArray,
                                        List <string> parentList, List <string> englishWordList, string prefix, TxtWord currentRoot, string nounRoot)
        {
            for (int i = 0; i < posArray.Length; i++)
            {
                if (parentList[1].Equals(posArray[i]))
                {
                    if (wordArray[i].Length == 0)
                    {
                        return(AddSuffix(suffixArray[i][0], prefix, currentRoot, nounRoot));
                    }
                    else
                    {
                        for (int j = 0; j < wordArray[i].Length; j++)
                        {
                            if (englishWordList[1].Equals(wordArray[i][j]))
                            {
                                return(AddSuffix(suffixArray[i][j], prefix, currentRoot, nounRoot));
                            }
                        }
                    }
                }
            }

            return(null);
        }
示例#19
0
 private void FocusWord(object sender, EventArgs e)
 {
     TxtWord.Focus();
 }
        protected string AddPassiveSuffix(string suffix1, string suffix2, string suffix3, string prefix, TxtWord root,
                                          string stem)
        {
            Transition transition;

            switch (root.VerbType())
            {
            case "F4PW":     //"nDH"
            case "F4PW-NO-REF":
                transition = new Transition(suffix1);
                break;

            case "F5PR-NO-REF":     //"DH"
            case "F5PL-NO-REF":
                transition = new Transition(suffix2);
                break;

            default:     //"HlDH"
                transition = new Transition(suffix3);
                break;
            }

            return(prefix + transition.MakeTransition(root, stem));
        }