Пример #1
0
        private static void SplitWordLists(string dictionary = "REVERSE.TXT")
        {
            var reader = File.OpenText(dictionary);
            var words  = new List <List <string> >();

            words.Add(new List <string>());
            words.Add(new List <string>());
            words.Add(new List <string>());
            words.Add(new List <string>());


            var word = reader.ReadLine();

            while (word != null)
            {
                word = word.Trim();
                if (word.IndexOf('-') == -1)
                {
                    var syllablesCount = Primer.GetSyllablesCount(word);
                    if (word.Length > 2 && syllablesCount > 0 && syllablesCount < 5)
                    {
                        var separ = Primer.setProb(word);
                        Debug.Assert(separ.Replace("-", string.Empty).Length == word.Length);
                        words[syllablesCount - 1].Add(separ);
                    }
                }
                word = reader.ReadLine();
            }
            reader.Close();

            for (int index = 0; index < words.Count; index++)
            {
                var list     = words[index];
                var fileName = (index + 1) + ".txt";
                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                }
                if (list.Count > 0)
                {
                    File.WriteAllLines(fileName, list);
                }
            }
        }