示例#1
0
        static void PrintTopWordCounts(int top)
        {
            using var stream = File.OpenRead(wordCountsPath);
            var wordCounts = VocabularyAssisstant.DeserializeWordCounts(stream);

            foreach (var wc in wordCounts.Take(top))
            {
                Console.WriteLine($"{wc.Word}: {wc.Count}");
            }
        }
示例#2
0
        static void CountWords()
        {
            var reader = new CorpusZipReader <IEnumerable <string> >(tokenizedPath, tokenizedDataSerializer);

            var wordCounts = VocabularyAssisstant.CountWords(
                reader,
                s => s.ToLower());

            using var stream = CreateOutputStream(wordCountsPath);
            VocabularyAssisstant.SerializeWordCounts(wordCounts, stream);
        }