0% found this document useful (0 votes)
20 views2 pages

Text Comparsion: Input

The document describes a program that will compare two texts and identify deletions, insertions, and changes between the two versions by listing the position and type of edit, number of characters affected, and before and after text. The input contains two strings representing different versions of a text, and the output lists the edits between the versions in a specified format including position, type of edit, length, and text details. Sample input and output are provided to illustrate the expected format for comparing two text versions and reporting the edits.

Uploaded by

Hello mister
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views2 pages

Text Comparsion: Input

The document describes a program that will compare two texts and identify deletions, insertions, and changes between the two versions by listing the position and type of edit, number of characters affected, and before and after text. The input contains two strings representing different versions of a text, and the output lists the edits between the versions in a specified format including position, type of edit, length, and text details. Sample input and output are provided to illustrate the expected format for comparing two text versions and reporting the edits.

Uploaded by

Hello mister
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

287 Text Comparsion

Write a program that will compare two texts. The two texts are assumed do be different versions of
the same text. Three different things can happen to a text between two versions:

• Text could be deleted

• Text could be inserted

• Text could be changed

Any combination of the three can occur at once. A move, for example will look as a deletion at
one place and an insert at another. You should list all changes that happened from the old to the new
version.

Input
The input file contains several datasets, each containing two lines with text1 and text2 strings. They
contain the two versions of the text to compare. String text2 should be regarded as the older version,
and string text1 as the newer.

Output
For each test case, the outputfile contain all deletions, insertions and changes that happended to the
text between the two versions in the following format:

• deletion: Position of the first character deleted, the word ‘deleted’ and the number of characters
deleted and the text that has been deleted.

• insertion: Position of the first character of the text inserted, the word ‘inserted’ since the last
version, the number of characters inserted an the text inserted.

• change: Position of the first character changed, the word ‘changed’, the number of characters
changed, the original text and what it has been changed to.

The position of the first character always refers to the position in the older version (i.e. the position
within text2). The first character in a file is numbered zero (0). The program should not be case-
sensitive.
Seee the sample below for details. Print a blank line after the output of each test case.
Note: The numbers for position characters and the headings of lines are not included in the input file.

Sample Input
0 1 2 3 4 5 6
0123456789012345678901234567890123456789012345678901234567890
text1: This is a joke. This is not life. Don't consider it anyway...
text2: This is not a joke. This is life. Consider it thoroughly...
Universidad de Valladolid OJ: 287 – Text Comparsion 2/2

Sample Output
pos 8 deleted 4 chars "not "
pos 28 inserted 4 chars "not "
pos 34 inserted 6 chars "don't "
pos 46 changed 10 chars from "thoroughly" to "anyway"

You might also like