Conversation
|
Please provide a detailed description of this PR. Ain't nobody got time for guessing what you try to do |
|
|
|
forward_annotations and backward_annotations are 1-to-1 mapping? YES |
|
Def: An annotation is a tuple contains two integers and a string. Two integers indicate the start and end positions of string to be transformed. The string in this repo must be the same as that original_string[start: end]. |
|
I hope that this method (annotation) can be used in "list of string" for recording the process of transformation by only changing the last part. |
|
transform should check that forward/backward are valid
|
| cls.test_cases = [ | ||
| { | ||
| "input_str": " 買5 - 80年 五門車~ ", | ||
| "reg_pattern": re.compile(r"\A\s+.{0,1}|.{0,1}\s+\Z"), |
There was a problem hiding this comment.
開頭 抓\s 和 0個或1個隨便的字元
結尾 也如此
search_all: Recursively search the substring that matches the given regular expression pattern. Meanwhile, collect the start and end positions of the matched substring.transform: Transform the string according to the provided annotations. A pair of annotations contains the forward and backward part. An annotation has format (start position, end position, substring). This method would extract the substring based on the positions provided by forward annotation and replace it with the substring provided by backward annotation.