/// <summary>
 /// processes both files, gets the words having the highest combined frequencies,
 /// then computes and displays the difference measure
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void uxAnalyze_Click(object sender, EventArgs e)
 {
     try
     {
         int[] words = new int[2];
         Dictionary <string, WordCount> dictionary = new Dictionary <string, WordCount>();
         words[0] = TextAnalyzer.ProcessFile(uxText1.Text, 0, dictionary);
         words[1] = TextAnalyzer.ProcessFile(uxText2.Text, 1, dictionary);
         MinPriorityQueue <float, WordFrequency> queue = TextAnalyzer.GetMostCommonWords(dictionary, words, (int)uxNumberOfWords.Value);
         MessageBox.Show("Difference Measure: " + TextAnalyzer.GetDifference(queue).ToString());
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Exemple #2
0
        }   //END OF UserInterface CONSTRUCTOR

        /// <summary>
        /// Method used to Analyze the text
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void uxAnalyze_Click(object sender, EventArgs e)
        {
            try
            {
                Dictionary<string, WordCount> dictonary = new Dictionary<string, WordCount>();
                int file1Words = TextAnalyzer.ProcessFile(uxText1.Text, 0, dictonary);
                int file2Words = TextAnalyzer.ProcessFile(uxText2.Text, 1, dictonary);
                int[] size = { file1Words, file2Words };
                MinPriorityQueue<float, WordFrequency> wordFrequencies = TextAnalyzer.GetMostCommonWord(dictonary, size, (int)uxNumberOfWords.Value);
                float answer = TextAnalyzer.GetDifference(wordFrequencies);
                MessageBox.Show("Difference Measure: " + answer.ToString());
            }   //END OF TRY BLOCK
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }   //END OF CATCH BLOCK
        }   //END OF uxAnalyze_Click METHOD
 /// <summary>
 /// Event handler for the uxAnalyze button.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void uxAnalyze_Click(object sender, EventArgs e)
 {
     try
     {
         Dictionary <string, WordCount> lookup = new Dictionary <string, WordCount>();
         int   x    = TextAnalyzer.ProcessFile(uxText1.Text, 0, lookup);
         int   y    = TextAnalyzer.ProcessFile(uxText2.Text, 1, lookup);
         int[] size = { x, y };
         MinPriorityQueue <float, WordFrequency> queue = TextAnalyzer.GetMostCommonWord(lookup, size, (int)uxNumberOfWords.Value);
         float result = TextAnalyzer.GetDifference(queue);
         MessageBox.Show(result.ToString());
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }