public static class SymbolsExtractor { private static readonly char[] _russianSymbols = "".ToCharArray(); // 33 public static char[] RussianSymbols => _russianSymbols.ToArray(); public static Dictionary<char, double> SymbolsFrequences(this string text) { var symbolsQty = text.ToCharArray().Count(symbol => _russianSymbols.Contains(symbol)); // ( ) double symbolPercentage = 1.00/symbolsQty; var result = new Dictionary<char, double>(); foreach (char russianSymbol in _russianSymbols) { double inclusions = text.ToLower().ToCharArray() .Count(textSymbol => textSymbol == russianSymbol) // * (symbolPercentage); // inclusions = Math.Round(inclusions, 3); // result.Add(russianSymbol, inclusions); } return result; // : } }
but | 0.0864 | 0.09 |
b | 0.0148 | 0.0172 |
at | 0.043 | 0.0388 |
g | 0.0164 | 0.0166 |
d | 0.0294 | 0.0292 |
... | ||
0 | 0 | |
s | 0.0228 | 0.0204 |
s | 0.0176 | 0.0186 |
uh | 0.0038 | 0.0042 |
Yu | 0.0064 | 0.0058 |
I | 0.0186 | 0.018 |
int result = 0; foreach (var stat in stats) { double MilfgardDiff = Math.Abs(stat.NewMilfgard - stat.Oxoron); // : Milfgard double AlizarDiff = Math.Abs(stat.Alizar - stat.Oxoron); // : Alizar char res = MilfgardDiff > AlizarDiff ? 'M' : Math.Abs(MilfgardDiff - AlizarDiff) < 0.0001 ? 'N' : 'A'; if (res == 'M') result++; // Milfgard if (res == 'A') result--; // Alizar } Console.WriteLine(); Console.WriteLine(result < 0 ? $"{-result} ALizar" : $"{result} Milfgard"); // . - 8 Alizar
Source: https://habr.com/ru/post/318864/
All Articles