Пример #1
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);
        }
Пример #2
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;
        }