Question: Following the comment to finish the code by python: Detect the revision tags in the diff.txt text, and divide it into delete, insert, and replace

Following the comment to finish the code by python:
Detect the revision tags in the diff.txt text, and divide it into delete, insert, and replace three types. The combination of modified text and error type is replaced by deletion and insertion. There is no blank in the middle. Delete: [-// -] Insert: {+ // +} Replace: [- // - ] {+ // +} After the detection, the number of statistical changes is the same, and are calculated separately. The calculation is divided into two kinds of deletion and insertion, and the replacement modification is included in the calculation of deletion and insertion, respectively. Calculate types directly without regard to deletion or insertion
import re from collections import Counter def main(text): # search for edits and print it (delete, insert, replace) for match in re.finditer(..., text): print() print(edit stats: # print edit stats #ex: # delete
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
