Exemplo n.º 1
0
        public void NounsAndVerbs()
        {
            var voc = Program.DefaultVocabulary;
            var verbs = voc.GetAllInfos().Where(s => s.PartOfSpeach == "V").Select(s => s.Stem);
            var nouns = voc.GetAllInfos().Where(s => s.PartOfSpeach == "S").Select(s => s.Stem);
            var ql = Program.DefaultQuestionList;
            var questionWords = ql.GetAllQuestions().SelectMany(q => q.WholeText.SplitInWordsAndStripHTML());
            var answerswords = ql.GetAllAnswers().SelectMany(a => a.Text.SplitInWordsAndStripHTML());
            var allWords = questionWords.Concat(answerswords);

            var verbFreq = new Func<SortedDictionary<string, int>>(
                () => WordsFrequensy(new HashSet<string>(verbs), allWords)).DetectTime("Verbs");
            File.WriteAllText(VerbsFileName, verbFreq.ToStringSortedByValue());
            var nounFreq = new Func<SortedDictionary<string, int>>(
                () => WordsFrequensy(new HashSet<string>(nouns), allWords)).DetectTime("Nouns");
            File.WriteAllText(NounsFileName, nounFreq.ToStringSortedByValue());
        }