-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#31] Add transform and search_all #31
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does the regex mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
開頭 抓\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.