コード例 #1
0
ファイル: Program.cs プロジェクト: kenwrites/HaikuMajigger
        /// <summary>
        /// Gets words from user, converts words to records, and sends records to syllable-counter service.  On receiving counts from service, displays counts to user and adds the to history.
        /// </summary>
        /// <param name="_history">The History object.</param>
        static void CountSyllables(History _history)
        {
            // get words from the user
            List <IWordReportPair> wordReportPairs = counterService.GetUserInput();

            // convert to Records
            List <IRecord> userRecords = new List <IRecord>();

            foreach (IWordReportPair pair in wordReportPairs)
            {
                userRecords.Add(new Record(pair));
            }

            // send Records to syllable-counter service

            List <IRecord> SimulatedSyllableCounts = counterService.Count(
                userRecords,
                ModelSelection.Simulator);

            List <IRecord> WrittenMethodSyllableCounts = counterService.Count(
                SimulatedSyllableCounts,
                ModelSelection.Written);

            // Below code will call machine-learning syllable counter model, when it's ready

            //List<IRecord> ClassifierSyllableCounts = counterService.Count(
            //    WrittenMethodSyllableCounts,
            //    ModelSelection.Option3);

            // On receiving syllable count, output to user
            Console.WriteLine("According to the \"Written Method\", your words have this many syllables: ");
            foreach (IRecord record in WrittenMethodSyllableCounts)
            {
                Console.WriteLine($"{record.Word} has {record.WrittenMethodGuess} syllables.  ({record.WrittenMethodCorrect})");
            }

            // Add to History
            foreach (IRecord record in WrittenMethodSyllableCounts)
            {
                _history.AddCounterRecord(record);
            }

            // Write History to disk
            _history.SerializeCounterRecords();
        }