示例#1
0
        private void buttonCompare_Click(object sender, EventArgs e)
        {
            Debug.WriteLine("Started comparing differences");

            DateTime startTime = DateTime.Now;

            string textUncorrected = textBoxUncorrected.Text;
            string textCorrected   = textBoxCorrected.Text;

            int numberOfDeletions    = 0;
            int numberOfAdditions    = 0;
            int numberOfReplacements = 0;

            string accuracyPercent;

            if (radioButtonDiffEngine.Checked)
            {
                accuracyPercent = ProcessDifferences(textUncorrected, textCorrected, ref numberOfDeletions,
                                                     ref numberOfAdditions, ref numberOfReplacements);
            }
            else
            {
                WordSequenceAligner           werEval   = new WordSequenceAligner();
                WordSequenceAligner.Alignment alignment = werEval.align(textCorrected.Split(' '), textUncorrected.Split(' '));

                numberOfDeletions    = alignment.numInsertions;
                numberOfAdditions    = alignment.numDeletions;
                numberOfReplacements = alignment.numSubstitutions;

                accuracyPercent = ((float)alignment.getNumCorrect() / (float)alignment.getReferenceLength() * 100.0).ToString("0.0");
            }
            TimeSpan timeTook = DateTime.Now - startTime;

            string message = String.Format("Number of deletions: {0}, ", numberOfDeletions);

            message += String.Format("additions: {0}, ", numberOfAdditions);
            message += String.Format("replacements: {0}{1}", numberOfReplacements, Environment.NewLine);
            message += String.Format("Percentage accuracy: {0}%{1}", accuracyPercent, Environment.NewLine);
            message += String.Format("Processing took {0} s", timeTook.TotalSeconds.ToString("0.000", CultureInfo.InvariantCulture));

            labelNumberOfDifferences.Text = message;
        }
示例#2
0
        private void buttonCompare_Click(object sender, EventArgs e)
        {
            Debug.WriteLine("Started comparing differences");

            DateTime startTime = DateTime.Now;

            string textUncorrected = textBoxUncorrected.Text;
            string textCorrected = textBoxCorrected.Text;

            int numberOfDeletions = 0;
            int numberOfAdditions = 0;
            int numberOfReplacements = 0;

            string accuracyPercent;
            if (radioButtonDiffEngine.Checked)
            {
                accuracyPercent = ProcessDifferences(textUncorrected, textCorrected, ref numberOfDeletions,
                                                         ref numberOfAdditions, ref numberOfReplacements);
            }
            else
            {
                WordSequenceAligner werEval = new WordSequenceAligner();
                WordSequenceAligner.Alignment alignment = werEval.align(textCorrected.Split(' '), textUncorrected.Split(' '));

                numberOfDeletions = alignment.numInsertions;
                numberOfAdditions = alignment.numDeletions;
                numberOfReplacements = alignment.numSubstitutions;

                accuracyPercent = ((float)alignment.getNumCorrect() / (float)alignment.getReferenceLength() * 100.0).ToString("0.0");
            }
            TimeSpan timeTook = DateTime.Now - startTime;

            string message = String.Format("Number of deletions: {0}, ", numberOfDeletions);
            message       += String.Format("additions: {0}, ", numberOfAdditions);
            message       += String.Format("replacements: {0}{1}", numberOfReplacements, Environment.NewLine);
            message       += String.Format("Percentage accuracy: {0}%{1}", accuracyPercent, Environment.NewLine);
            message       += String.Format("Processing took {0} s", timeTook.TotalSeconds.ToString("0.000", CultureInfo.InvariantCulture));

            labelNumberOfDifferences.Text = message;
        }