You are on page 1of 9

String Difference Algorithm in C++

 We need a string comparision solution in C++.


 There would be two strings the first is the Original Text and second is the Text to
Compare.
 The string text may contain English text or Hindi unicode text. So the text is a unicode
string.
 Compariosion will be done between the Original Text and the Text to Compare strings.
Comparision will be based on words instead of characters.
 Matched words will be considred as correct words and mis-matched words will be
considered as errors/mistakes.
 We will required the source code. The source code should be well explained and
documented, proper comments should be there wherever required.

Meaning and nature of word errors


A. Full Mistakes : The following errors are treated as full mistakes :
(i) For every omission of word/ figure.

(ii) For every substitution of a wrong word /figure.

(iii) For every addition of a word / figure not found in the passage.

B. Half Mistakes : The following errors are treated as half mistakes :

(i) Spacing Errors : Where no space is provided between two words, e.g. ‘Ihope’ or undesired
space is provided between the words or letters of a word e.g. hope I have, ‘I hxxave’.

(ii) For every spelling error committed by way of repetition, or addition or transposition or
omission or substitution of a letter/letters, e.g. the word ‘spelling’ typed as ‘seeplings’ etc.

(iii) Wrong Capitalisation : Wrong use of capital letter for small letter and vice-versa. (This does
not apply to Hindi typewriting scripts).

Algorithm Inputs
1. Original Text
2. Text to compare
Algorithm Outputs
1. Simple HTML output of “Text to Compare” which shows
a. Full mistakes in the red color,
b. Half mistakes in blue color and
c. Correct words in green color

The HTML text output will be of string data type in C++ so it can be used
whenever required.

2. Result statistics which should be generated along with the above HTML output
separately
 Number of totol words in original text
 Number of total words in text to compare text
 Number of Correct words and list of those words considered correct
 Number of Mistakes and list of those words considered a mistake
o Full Mistakes
 Ommission of words (Number count and word list)
 Substitution/addition of word (Number count and word list)
o Half Mistakes
 Spacing errors (Number count and word list)
 Wrong capitalisation errors (Number count and word list)
 Spelling errors (Number count and word list)

The solution should follow the object oriented programming norms.


Use Cases for testing
Note:- This list is only to assist the developer to understand the problem clearly. We may test even more
use cases with other text examples before accepting the final solution from your side.

Case – 1: Ommission Error (Full mistake)


Original Text

Once upon a time there was a crow. It was very thirsty. It flew here and
there in search of water.

Text to Compare

Once there was a crow. It was very thirsty. It flew here and there in the
search of water.

Desired HTML Output

Once upon a time there was a crow. It was very thirsty. It flew here and
there in the search of water.

Case – 2 : Substitution Error (Full Mistake)


Original Text

Once upon a time there was a crow. It was very thirsty. It flew here and
there in search of water.

Text to Compare

Once upon upon a time there was a crow. It was very thirsty. It flew here
and there in the search of water.

Desired HTML Output

Once upon upon a time there was a crow. It was very thirsty. It flew here
and there in the search of water.
Case – 3 : Substitution Error (Full Mistake)
Original Text

Once upon a time there was a crow. It was very thirsty. It flew here and
there in search of water.

Text to Compare

Once upon a time there was a crow. There was a crow. It was very thirsty. It
flew here and there in search of water.

Desired HTML Output

Once upon a time there was a crow. There was a crow. It was very thirsty. It
flew here and there in search of water.

Case – 4 : Substitution Error (Full Mistake)


Original Text

Once upon a time there was a crow. It was very thirsty. It flew here and
there in search of water.

Text to Compare

Once upon a time there was a crow. He was very angry. It was very thirsty.
It flew here and there in search of water.

Desired HTML Output

Once upon a time there was a crow. He was very angry. It was very thirsty.
It flew here and there in search of water.
Case – 5 : Incorrect word typed (Full Mistake)
Original Text

Once upon a time there was a crow. It was very thirsty. It flew here and
there in search of water.

Text to Compare

Once sdrt a time the was a crow. It was very thirsty. It flew here and there in
search of water.

Desired HTML Output

Once sdrt a time the was a crow. It was very thirsty. It flew here and there in
search of water.

Case – 6 : Ommission of text (Full Mistake)


Original Text

Once upon a time there was a crow. It was very thirsty. It flew here and
there in search of water.

Text to Compare

Once upon a time there was a crow. It flew here and there in search of
water.

Desired HTML Output

Once upon a time there was a crow. It was very thirsty. It flew here and
there in search of water.
Case – 7 : Transpostion of characters in a word ( half mistake)
Original Text

Once upon a time there was a crow. It was very thirsty. It flew here and
there in search of water.

Text to Compare

Once upon a time there was a crow. It saw very thirsty. It flew here and
there in search of water.

Desired HTML Output

Once upon a time there was a crow. It saw very thirsty. It flew here and
there in search of water.

Case – 8 : Wrong capitalisation ( half mistake)

Original Text

Once upon a time there was a crow. It was very thirsty. It flew here and
there in search of water.

Text to Compare

Once upon a time there was a crow. It was very thirsty. It flew here and
there in search of Water.

Desired HTML Output

Once upon a time there was a crow. It was very thirsty. It flew here and
there in search of water.
Case – 9 : Spacing error ( half mistake)
Original Text

Once upon a time there was a crow. It was very thirsty. It flew here and
there in search of water.

Text to Compare

Once upon a time there was a crow. It w as very thirsty. It flew here and
there in search of water.

Desired HTML Output

Once upon a time there was a crow. It w as very thirsty. It flew here and
there in search of water.

Case – 10 : Spacing error ( half mistake)


Original Text

Once upon a time there was a crow. It was very thirsty. It flew here and
there in search of water.

Text to Compare

Once upon a time there was a crow. Itwas very thirsty. It flew here and
there in search of water.

Desired HTML Output

Once upon a time there was a crow. Itwas very thirsty. It flew here and
there in search of water.
Case – 11 : Ommission of letter (half mistake)
Ommission of word is a full mistake but the ommission of letter in a word is considered half mistake.

Original Text

Once upon a time there was a crow. It was very thirsty. It flew here and
there in search of water.

Text to Compare

Once upon a time there was a crow. It was very thrsty. It flew here and
there in search of water.

Desired HTML Output

Once upon a time there was a crow. It was very thrsty. It flew here and
there in search of water.

Case – 12 : Substitution of letter (half mistake)


Substitution of word is a full mistake but the substitution of letter in a word is considered half mistake.

Original Text

Once upon a time there was a crow. It was very thirsty. It flew here and
there in search of water.

Text to Compare

Once upon a time there was a crow. It was very tharsty. It flew here and
there in search of water.

Desired HTML Output

Once upon a time there was a crow. It was very tharsty. It flew here and
there in search of water.
Case – 13 : Ommission of punctuation mark like full stop, comma, question mark,
inverted comma etc. (half mistake)
Original Text

Once upon a time there was a crow. It was very thirsty. It flew here and
there in search of water.

Text to Compare

Once upon a time there was a crow It was very thirsty. It flew here and
there in search of water.

Desired HTML Output

Once upon a time there was a crow It was very thirsty. It flew here and
there in search of water.

You might also like