-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
28 lines (26 loc) · 959 Bytes
/
Program.cs
File metadata and controls
28 lines (26 loc) · 959 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System;
using System.Collections.Generic;
using System.IO;
using NUnitLite;
namespace TextAnalysis
{
internal static class Program
{
public static void Main(string[] args)
{
var text = File.ReadAllText("HarryPotterText.txt");
var sentences = SentencesParser.ParseSentences(text);
var frequency = FrequencyAnalysis.GetMostFrequentNextWords(sentences);
while (true)
{
var rnd = new Random();
var count = rnd.Next(0, 40);
Console.Write("Введите первое слово (например, harry): ");
var beginning = Console.ReadLine();
if (string.IsNullOrEmpty(beginning)) return;
var phrase = TextGenerator.ContinuePhrase(frequency, beginning.ToLower(), count);
Console.WriteLine(phrase);
}
}
}
}