There is the variable "my name is Anton and I change the text."
I am correcting and sending "Hi my name is Antonio and I changes this text."

I am receiving text correction data lines in the following format ...

[(1, 'Hi'), (0, ' my name is Anton'), (1, 'io'), (0, ' and I change'), (1, 's'), (0, ' th'), (-1, 'e'), (1, 'is'), (0, ' text.')] 

Tell me how I need to extract the data so that they can be output in the format .. enter image description here

  • To know where the edits were, you need to know where the edits were. There is no such information with the specified data. At a minimum, starting and ending positions of edits are needed. - Adokenai

1 answer 1

Algorithm:

We take each pair number string.

  • if the number is 1, then the line is displayed in color for the added text (green),
  • if the number is 0, then the string is displayed in the default color (black),
  • if the number is -1, then the line is displayed in color for the deleted text (red).

Taking into account the above, we collect the final line from the original fragments in the order in which the data goes. Profit

  • My question is what you need to implement - "We take every couple number-string." and in the array - Anton Mudrak