Ejemplo n.º 1
0
 /// <summary>
 /// Shows that a topic completed downloading its seed docs in the box on the right.
 /// </summary>
 /// <param name="topicNumber">The topic number.</param>
 public void ShowTestFinish(int topicNumber, TestResults results)
 {
     if (textWindow.InvokeRequired)
     {
         threadProgressText.Invoke(new MethodInvoker(delegate() { ShowTestFinish(topicNumber, results); }));
     }
     else
     {
         threadProgressText.Text += "Topic " + topicNumber + " finished testing\n";
         testsCompleted++;
         if (testsCompleted == globalTotalTopics)
         {
             lock (testLockObject)
             {
                 overallTestAccuracy += results.accuracy;
                 overallTestAccuracy /= globalTotalTopics;
             }
             string overallResult = String.Format("Tests completed. Overall accuracy: {0:0.00}\n", overallTestAccuracy);
             SetRichText(overallResult);
             ShowMessageBox(overallResult);
             SetButtonsEnabled(true);
         }
         else
         {
             lock (testLockObject)
             {
                 overallTestAccuracy += results.accuracy;
             }
         }
     }
 }
Ejemplo n.º 2
0
        private TestResults Test(int whereToStart)
        {
            TestResults results = new TestResults();
            // Positive
            for (int i = whereToStart; true; i++)
            {
                string fileName = mainDirectory + TopicDir + Path.DirectorySeparatorChar + i + ".txt";
                if (!File.Exists(fileName))
                {
                    break;
                }
                string fileContent = File.ReadAllText(fileName);
                string useableText = ExtractUseableText(fileContent);

                bool isMatch = classifier.IsMatch(useableText);
                // it's a positive link
                results.numberOfTestForPos++;
                if (!isMatch)
                {
                    results.falseNeg++;
                }
            }
            // Negative
            for (int i = whereToStart; true; i++)
            {
                string fileName = mainDirectory + "neg" + Path.DirectorySeparatorChar + i + ".txt";
                if (!File.Exists(fileName))
                {
                    break;
                }
                string fileContent = File.ReadAllText(fileName);
                string useableText = ExtractUseableText(fileContent);

                bool isMatch = classifier.IsMatch(useableText);
                // it's a negative link
                results.numberOfTestsForNeg++;
                if (isMatch)
                {
                    results.falsePos++;
                }
            }

            // Calculate accuracy
            int testsTotal = results.numberOfTestForPos + results.numberOfTestsForNeg;
            results.accuracy = ((double)(testsTotal - results.falseNeg - results.falsePos))/testsTotal;

            return results;
        }