Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private Trie game_dictionary = new Trie();
- private bool loading_dictionary = true;
- private void GenerateDictionary(object path)
- {
- var uri = new Uri(path.ToString());
- var resourceStream = Application.GetResourceStream(uri);
- using (StreamReader sr = new StreamReader(resourceStream.Stream))
- {
- while (sr.Peek() >= 0)
- {
- string word = sr.ReadLine(); //only one word per line in PolishDictionary
- if (game_dictionary.AcceptableWord(word)) game_dictionary.AddWord(word);
- }
- }
- using (var fs = new System.IO.FileStream("dict.dat", FileMode.CreateNew, FileAccess.Write))
- {
- var bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
- bf.Serialize(fs, game_dictionary);
- }
- loading_dictionary = false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement