Ejemplo n.º 1
0
        private Trigram GetNextTrigram(Trigram currentTrigram)
        {
            List <Trigram> trigramOptions = trigrams.Where(checkedTrigram => checkedTrigram.firstWord == currentTrigram.secondWord && checkedTrigram.secondWord == currentTrigram.thirdWord).ToList <Trigram>();

            if (trigramOptions.Count == 0)
            {
                trigramOptions = trigrams;
            }
            Random r = new Random();

            return(trigramOptions[r.Next(trigramOptions.Count - 1)]);
        }
Ejemplo n.º 2
0
        public void Write()
        {
            Trigram currentTrigram = new Trigram("", "", "");

            using (StreamWriter sw = File.AppendText(outFile))
            {
                for (int i = 0; i <= wordCount; i++)
                {
                    currentTrigram = GetNextTrigram(currentTrigram);
                    sw.Write(currentTrigram.firstWord.Replace("\n", ""));
                    sw.Write(" ");
                }
                sw.Flush();
            }
        }