<s> import re <EOL> def get_word_set ( url ) : <EOL> question_mark_index = url . find ( '<STR_LIT:?>' ) <EOL> url = url [ : question_mark_index ] if question_mark_index > - <NUM_LIT:1> else url <EOL> return set ( re . split ( '<STR_LIT>' , url ) ) <EOL> def get_similarity ( url1 , ws2 , sc2 ) : <EOL> ws1 = get_word_set ( url1 ) <EOL> if ws1 == ws2 : <EOL> return ( <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> return - abs ( url1 . count ( '<STR_LIT:/>' ) - sc2 ) , len ( ws1 & ws2 ) / len ( ws2 ) <EOL> def get_sorted_links ( urls , request_url ) : <EOL> wsr = get_word_set ( request_url ) <EOL> slash_count = request_url . count ( '<STR_LIT:/>' ) <EOL> return sorted ( set ( urls ) , key = lambda u : get_similarity ( u , wsr , slash_count ) , reverse = True ) </s>
