Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
846 B
5
Indexable
Never
 static void writeFile(string fileName)
        {
            const int MAX_FILE_LINES = 50000;
            string[] AllLines = new string[MAX_FILE_LINES];

            AVLTree<string> tree = new AVLTree<string>();

            AllLines = File.ReadAllLines(fileName);

            foreach(string line in AllLines)
            {
                string[] words = line.Split(' ', ',', '.', '?', ';', ':', '!');
                foreach (string word in words)
                    if (word != "")
                        //  Console.WriteLine(word.ToLower());
                        tree.InsertItem(word.ToLower());
            }
            StreamWriter sw = new StreamWriter(fileName);
            sw.WriteLine("Number of words {0}", tree.Count());
          // sw.WriteLine("Number of times each word appears {0}",  );
        }