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

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 : count print) print( 'edit type stats: # print edit type stats #ex: # : count if_namemain' main(open('diff.txt').read)) 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 : count print) print( 'edit type stats: # print edit type stats #ex: # : count if_namemain' main(open('diff.txt').read))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!