-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
50 lines (39 loc) · 1.35 KB
/
Program.cs
File metadata and controls
50 lines (39 loc) · 1.35 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
namespace Decoder
{
class Program
{
static void Main(string[] args)
{
var reader = new StreamReader("text.txt",Encoding.GetEncoding(1251));
string srcText = reader.ReadToEnd();
reader.Close();
string proposalPattern = @"(^(\w+ая)|(\w+ее)|(\w+ое)|(\w+ый)|(\w+ой)|\n$)";
var proposalRegex = new Regex(proposalPattern);
var decodedText = new StringBuilder();
Console.WriteLine("Please wait... Text is analysing....\n");
foreach(Match m in Regex.Matches(srcText,@"(\w+)|[.,!-?()]"))
{
if(proposalRegex.IsMatch(m.ToString()))
{
decodedText.Append("ГАВ").Append(" ");
}
else
{
decodedText.Append(m).Append(" ");
}
}
var writer = new StreamWriter("text.txt");
writer.Write(decodedText);
writer.Close();
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("\nDone!");
Console.Beep();
Console.ForegroundColor = ConsoleColor.Gray;
Console.ReadKey();
}
}
}