<s> def overlaps ( s1 , s2 ) : <EOL> return max ( <NUM_LIT:0> , min ( s1 . end , s2 . end ) - max ( s1 . start , s2 . start ) ) <EOL> def compare_junctions ( r1 , r2 , internal_fuzzy_max_dist = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> found_overlap = False <EOL> for i , x in enumerate ( r1 . segments ) : <EOL> for j , y in enumerate ( r2 . segments ) : <EOL> if i > <NUM_LIT:0> and j > <NUM_LIT:0> : break <EOL> if overlaps ( x , y ) > <NUM_LIT:0> : <EOL> found_overlap = True <EOL> break <EOL> if found_overlap : <EOL> break <EOL> if not found_overlap : return "<STR_LIT>" <EOL> if len ( r1 . segments ) == <NUM_LIT:1> : <EOL> if len ( r2 . segments ) == <NUM_LIT:1> : return "<STR_LIT>" <EOL> else : <EOL> if r1 . segments [ <NUM_LIT:0> ] . end <= r2 . segments [ j ] . end : <EOL> return "<STR_LIT>" <EOL> else : <EOL> return "<STR_LIT>" <EOL> else : <EOL> if len ( r2 . segments ) == <NUM_LIT:1> : return "<STR_LIT>" <EOL> else : <EOL> k = <NUM_LIT:0> <EOL> while i + k + <NUM_LIT:1> < len ( r1 . segments ) and j + k + <NUM_LIT:1> < len ( r2 . segments ) : <EOL> if abs ( r1 . segments [ i + k ] . end - r2 . segments [ j + k ] . end ) > internal_fuzzy_max_dist or abs ( r1 . segments [ i + k + <NUM_LIT:1> ] . start - r2 . segments [ j + k + <NUM_LIT:1> ] . start ) > internal_fuzzy_max_dist : <EOL> return "<STR_LIT>" <EOL> k += <NUM_LIT:1> <EOL> print i , j , k <EOL> if i + k + <NUM_LIT:1> == len ( r1 . segments ) : <EOL> if j + k + <NUM_LIT:1> == len ( r2 . segments ) : <EOL> if i == <NUM_LIT:0> : <EOL> if j == <NUM_LIT:0> : return "<STR_LIT>" <EOL> else : return "<STR_LIT>" <EOL> else : return "<STR_LIT>" <EOL> else : <EOL> if i == <NUM_LIT:0> : return "<STR_LIT>" <EOL> else : <EOL> if abs ( r1 . segments [ i + k - <NUM_LIT:1> ] . end - r2 . segments [ j + k - <NUM_LIT:1> ] . end ) > internal_fuzzy_max_dist or abs ( r1 . segments [ i + k ] . start - r2 . segments [ j + k ] . start ) > internal_fuzzy_max_dist : <EOL> return "<STR_LIT>" <EOL> else : <EOL> return "<STR_LIT>" <EOL> else : <EOL> if j == <NUM_LIT:0> : return "<STR_LIT>" <EOL> else : <EOL> if abs ( r1 . segments [ i + k - <NUM_LIT:1> ] . end - r2 . segments [ j + k - <NUM_LIT:1> ] . end ) > internal_fuzzy_max_dist or abs ( r1 . segments [ i + k ] . start - r2 . segments [ j + k ] . start ) > internal_fuzzy_max_dist : <EOL> return "<STR_LIT>" <EOL> else : <EOL> return "<STR_LIT>" </s>
