def normalize_query(query_string,<EOL>findterms=re.compile(r'<STR_LIT>').findall,<EOL>normspace=re.compile(r'<STR_LIT>').sub):
return [normspace('<STR_LIT:U+0020>', (t[<NUM_LIT:0>] or t[<NUM_LIT:1>]).strip()) for t in findterms(query_string)]<EOL>
Split the query string into individual keywords, discarding spaces
and grouping quoted words together.

>>> normalize_query('  some random  words "with   quotes  " and   spaces')
['some', 'random', 'words', 'with quotes', 'and', 'spaces']