Exemple #1
0
 private static void PrintDifferences(int index, int length, DifferenceListWordList sourceFile, string differenceName)
 {
     Debug.WriteLine(differenceName);
     for (int i = 0; i < length; i++)
     {
         var word = sourceFile.GetByIndex(index + i);
         Debug.WriteLine(((Word)word).WordProp);
     }
 }
 private static void PrintDifferences(int index, int length, DifferenceListWordList sourceFile, string differenceName)
 {
     Debug.WriteLine(differenceName);
     for (int i = 0; i < length; i++)
     {
         var word = sourceFile.GetByIndex(index + i);
         Debug.WriteLine(((Word) word).WordProp);
     }
 }
Exemple #3
0
        private string ProcessDifferences(string textSource, string textDestination, ref int numberOfDeletions,
                                          ref int numberOfAdditions, ref int numberOfReplacements)
        {
            SimplifyText(ref textSource);
            SimplifyText(ref textDestination);

            try
            {
                DifferenceEngine differenceEngine = new DifferenceEngine();

                DifferenceListWordList sourceFile      = new DifferenceListWordList(textSource);
                DifferenceListWordList destinationFile = new DifferenceListWordList(textDestination);

                differenceEngine.ProcessDifferences(sourceFile, destinationFile, DifferenceEngineLevel.SlowPerfect);

                ArrayList diffReport = differenceEngine.DifferenceReport();

                foreach (DifferenceResultSpan difference in diffReport)
                {
                    switch (difference.Status)
                    {
                    case DifferenceResultStatus.DeleteSource:
                        PrintDifferences(difference.SourceIndex, difference.Length, sourceFile, "DeleteSource:");
                        numberOfDeletions += difference.Length;
                        break;

                    case DifferenceResultStatus.AddDestination:
                        PrintDifferences(difference.DestIndex, difference.Length, destinationFile, "AddDestination:");
                        numberOfAdditions += difference.Length;
                        break;

                    case DifferenceResultStatus.Replace:
                        PrintDifferences(difference.DestIndex, difference.Length, destinationFile, "Replace:");
                        numberOfReplacements += difference.Length;
                        break;

                    case DifferenceResultStatus.NoChange:
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to process the differences in the transcription. Error: " + ex.Message);
            }

            double accuracy = 1.0 -
                              ((double)(numberOfAdditions + numberOfReplacements) /
                               (double)GetNumberOfWordsInString(textBoxCorrected.Text));
            string accuracyPercent = (accuracy * 100.0).ToString("0.0");

            return(accuracyPercent);
        }
        private string ProcessDifferences(string textSource, string textDestination, ref int numberOfDeletions,
                                          ref int numberOfAdditions, ref int numberOfReplacements)
        {
            SimplifyText(ref textSource);
            SimplifyText(ref textDestination);

            try
            {
                DifferenceEngine differenceEngine = new DifferenceEngine();

                DifferenceListWordList sourceFile = new DifferenceListWordList(textSource);
                DifferenceListWordList destinationFile = new DifferenceListWordList(textDestination);

                differenceEngine.ProcessDifferences(sourceFile, destinationFile, DifferenceEngineLevel.SlowPerfect);

                ArrayList diffReport = differenceEngine.DifferenceReport();

                foreach (DifferenceResultSpan difference in diffReport)
                {
                    switch (difference.Status)
                    {
                        case DifferenceResultStatus.DeleteSource:
                            PrintDifferences(difference.SourceIndex, difference.Length, sourceFile, "DeleteSource:");
                            numberOfDeletions += difference.Length;
                            break;
                        case DifferenceResultStatus.AddDestination:
                            PrintDifferences(difference.DestIndex, difference.Length, destinationFile, "AddDestination:");
                            numberOfAdditions += difference.Length;
                            break;
                        case DifferenceResultStatus.Replace:
                            PrintDifferences(difference.DestIndex, difference.Length, destinationFile, "Replace:");
                            numberOfReplacements += difference.Length;
                            break;
                        case DifferenceResultStatus.NoChange:
                            break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to process the differences in the transcription. Error: " + ex.Message);
            }

            double accuracy = 1.0 -
                              ((double) (numberOfAdditions + numberOfReplacements)/
                               (double) GetNumberOfWordsInString(textBoxCorrected.Text));
            string accuracyPercent = (accuracy*100.0).ToString("0.0");
            return accuracyPercent;
        }