// Constructor just takes the filename
        public Dictionary(String filename)
        {
            if (filename!=null && filename.Length!=0) {

                string line;
                Node currentNode=null;
                string currentLetter="";
                Alphabets = new Dictionary<string, Node>();

                // Read the file and display it line by line.
                try
                {
                    //Reading the file
                    System.IO.StreamReader file = new System.IO.StreamReader(filename);
                    while ((line = file.ReadLine()) != null)
                    {
                        //Removing leading and trailing whitespaces
                        line = line.Trim();

                        //For adding all the words starting with currentLetter.
                        //Note: Will never go in the first time
                        if (line.Substring(0, 1).Equals(currentLetter))
                        {
                            //Adding the word in the alphabetical node
                            currentNode.add(line.Substring(0, 2), line);
                        }
                        // Program enters else only when currentLetter needs to change .
                        //For e.g: a needs to become b
                        else
                        {
                            // Condition only required the first time program enters the while loop
                            if (currentNode != null)
                                this.Alphabets.Add(currentLetter, currentNode);

                            //Getting the current alphabet and reinitialzing the currentNode for the alphabet
                            currentLetter = line.Substring(0, 1);
                            currentNode = new Node(currentLetter);

                            // Adding the first word for the new selected alphabet in the file
                            currentNode.add(line.Substring(0, 2), line);
                        }

                    }

                    //This condition is required for the very last alphabet in the file e.g: z
                    if (currentNode != null)
                    {
                        this.Alphabets.Add(currentLetter, currentNode);
                    }

                    file.Close();
                }
                // In case file is not found
                catch (System.IO.FileNotFoundException) {
                    this.Alphabets = new Dictionary<string, Node>();
                };

            }
        }
        /*****************/
        public Test()
        {
            //The following four lists should have matching segments and words at the same index ideally

            /***************************************/
            this.correctSegments = new String[20]
                {"foo", "garb","accom","acknowle","argue","comit","deduct","depi","exist","forwor",
                    "herr","inadv","judgem","ocu","paro","superi","abla","brav","hub","cooi"};
            /***************************************/

            /***************************************/
            this.InCorrectSegments = new String[20]
                {"foob","garbga","accomood","acknowleg","arguem","comitm","deducta","depinda","existan","forword",
                    "herras","inadvarte","judgeman","ocurr","parogat","supar","ablabc","brafcd","hubz","cooibn" };
            /***************************************/

            /***************************************/
            this.CorrectWords = new String[20]
                {"food", "garbage","accommodate","acknowledge","arguers","comitia","deductible","depict","existed","forworn",
                    "herring","inadvertent","judgement","ocular","parody","super","ablaze","bravo","hubby","cooing"};
            /***************************************/

            /***************************************/
            this.inCorrectWords = new String[20]
                {"foobar","garbgae","accomodate","acknowlegement","arguemint","comitmment","deductabel","depindant","existanse","forworde",
                     "herrass","inadvartent","judgemant","ocurrance","parady","superas","ablize","bravfi","hubay","cooibng"};
            /***************************************/

            //Sometimes a segment is also a word

            /***************************************/
            this.whethersegmentisAlsoAWord = new Dictionary<string, bool>();

            for (int run = 0; run < this.correctSegments.Count(); run++)
                this.whethersegmentisAlsoAWord.Add(this.correctSegments[run], false);

            this.whethersegmentisAlsoAWord["argue"] = true;
            this.whethersegmentisAlsoAWord["deduct"] = true;
            this.whethersegmentisAlsoAWord["exist"] = true;
            this.whethersegmentisAlsoAWord["garb"] = true;
            this.whethersegmentisAlsoAWord["hub"] = true;
            /***************************************/

            // Run this list in changePopularity function

            /***************************************/
            this.frequentWords = new String[]
                {"for","for","form","form","form","format","format","formatting","axes","axile","axilla",
                    "axilla","bawd","bawd","bawd","bawd","bawdier","bawdier","bawdier","bawdiest"};
            /***************************************/

            //Strings in listOfSegments have to exist as key in frequencyAnswers

            /***************************************/
            this.listOfSegments = new String[]
            {"fo","for","form","forma","formatt","ax","axe","axi","axil","axile","baw","bawd","bawdie","bawdies","bawdiest" };
            /***************************************/

            // Values in frequency have to determined from frequencyWords array
            //Note: Remember that popularity of a word depends on how many times it has been used

            /***************************************/
            this.frequencyAnswers = new Dictionary<string, string>();

            this.frequencyAnswers.Add("fo","form");
            this.frequencyAnswers.Add("for", "form");
            this.frequencyAnswers.Add("form", "form");
            this.frequencyAnswers.Add("forma", "format");
            this.frequencyAnswers.Add("formatt", "formatting");
            this.frequencyAnswers.Add("ax", "axilla");
            this.frequencyAnswers.Add("axe", "axes");
            this.frequencyAnswers.Add("axi", "axilla");
            this.frequencyAnswers.Add("axil","axilla");
            this.frequencyAnswers.Add("axile", "axile");
            this.frequencyAnswers.Add("baw", "bawd");
            this.frequencyAnswers.Add("bawd", "bawd");
            this.frequencyAnswers.Add("bawdie", "bawdier");
            this.frequencyAnswers.Add("bawdies","bawdiest");
            this.frequencyAnswers.Add("bawdiest", "bawdiest");
            /***************************************/

            Console.Write("Type in file name:");
            string file=Console.ReadLine();

            this.d = new Dictionary(file);

            // Changing popularity of words
            for (int run = 0; run < this.frequentWords.Count(); run++)
                this.d.changeWordPopularity(this.frequentWords[run]);

            Console.WriteLine("++++++++++++++++++++++++++++++++");
        }
            //letter is segment of words.status is whether the segment is an actual word.By default it is false
            public Node(string letter, bool status = false)
            {
                //Basic validation
                if (letter.Length != 0)
                {
                    this.Data = letter;
                    Children = new Dictionary<String, Node>();
                    SimilarWords = new Dictionary<int, List<String>>();
                    this.Popularity = new Dictionary<string, int>();
                }
                else
                {
                    this.Data = null;
                    this.Children = null;
                    this.SimilarWords = null;
                    this.Popularity = null;
                }

                this.isAWord = status;
            }