Exemple #1
0
        public Word GetWord(bool newWord)
        {
            Debug.Assert(mPlainListWords.Count == mTranslations.Count);

            if (mTranslations.Count == 0)
            {
                return(new Word("nothing", "to do", "here"));
            }

            //--
            if (newWord)
            {
                mCurrentWordIdx = Convert.ToInt32(mTriangleDistr.NextDouble() * (mPlainListWords.Count - 1));
            }

            //--
            string word = mPlainListWords[mCurrentWordIdx].Key;

            //--
            Translations translations = mTranslations[word];

            if (newWord)
            {
                translations.frequency++;
            }

            //-- update the frequency in the plain list.
            mPlainListWords[mCurrentWordIdx] = new KeyValuePair <string, int>(word, translations.frequency);

            //--
            if (newWord)
            {
                mCurrentTranslationIdx = mRnd.Next(0, translations.translations.Count - 1);
            }
            Translation t = translations.translations[mCurrentTranslationIdx];

            if (newWord)
            {
                t.frequency++;
            }

            return(new Word(word + " " + mCurrentWordIdx.ToString(), t.part, t.translation));
        }