Fix letters 'q' and 'z' not being in the dictionary

Enfore that all one-grams are present in the dictionary to make sure
it's possible to write any sentence
This commit is contained in:
2025-05-17 00:25:51 +02:00
parent 623888851b
commit 5917e79635
2 changed files with 327 additions and 321 deletions

View File

@@ -56,7 +56,7 @@ Console.WriteLine("Computing ngrams");
var ngrams = new Dictionary<string, long>();
const int MaxLength = 8;
const int MinLength = 1;
const int MinLength = 2;
foreach (var (word, frequency) in wordFrequencies)
{
@@ -112,9 +112,15 @@ Console.WriteLine("Generating dictionary...");
var dictionary = new Dictionary<string, string>();
var ngramIndex = 0;
// Prepend base letters to make sure all words are writeable
string[] oneGrams = [
" ", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"
];
var fullNgrams = oneGrams.Concat(orderedNgrams.Select(p => p.Key)).ToArray();
foreach (var letter in Alphabet.BaseAlphabet)
{
dictionary[letter] = orderedNgrams[ngramIndex].Key;
dictionary[letter] = fullNgrams[ngramIndex];
ngramIndex++;
}