<s> import regex <EOL> def separate_string ( string ) : <EOL> """<STR_LIT>""" <EOL> string_list = regex . split ( r'<STR_LIT>' , regex . sub ( r'<STR_LIT:>>' , '<STR_LIT:<>' , string ) ) <EOL> return string_list [ : : <NUM_LIT:2> ] , string_list [ <NUM_LIT:1> : : <NUM_LIT:2> ] <EOL> def overlapping ( start1 , end1 , start2 , end2 ) : <EOL> """<STR_LIT>""" <EOL> return not ( ( start1 <= start2 and start1 <= end2 and end1 <= end2 and end1 <= start2 ) or <EOL> ( start1 >= start2 and start1 >= end2 and end1 >= end2 and end1 >= start2 ) ) <EOL> def overlapping_at ( start , end , current ) : <EOL> for current_index , ( _ , c_start , c_end ) in enumerate ( current ) : <EOL> if overlapping ( c_start , c_end , start , end ) : <EOL> yield current_index <EOL> def remove_lower_overlapping ( current , higher ) : <EOL> """<STR_LIT>""" <EOL> for ( match , h_start , h_end ) in higher : <EOL> overlaps = list ( overlapping_at ( h_start , h_end , current ) ) <EOL> for overlap in overlaps : <EOL> del current [ overlap ] <EOL> if len ( overlaps ) > <NUM_LIT:0> : <EOL> current . insert ( overlaps [ <NUM_LIT:0> ] , ( match , h_start , h_end ) ) <EOL> else : <EOL> current . append ( ( match , h_start , h_end ) ) <EOL> return current </s>
