<s> def process_question ( qtxt ) : <EOL> question = '<STR_LIT>' <EOL> skip = False <EOL> for letter in qtxt : <EOL> if letter == '<STR_LIT:<>' : <EOL> skip = True <EOL> if letter == '<STR_LIT:>>' : <EOL> skip = False <EOL> if skip : <EOL> continue <EOL> if letter . isalnum ( ) or letter == '<STR_LIT:U+0020>' : <EOL> if letter == '<STR_LIT:U+0020>' : <EOL> letter = '<STR_LIT:_>' <EOL> question += letter . lower ( ) <EOL> return question <EOL> def process_h3 ( h3 , l ) : <EOL> endh3 = l . find ( "<STR_LIT>" ) <EOL> qtxt = l [ h3 + <NUM_LIT:4> : endh3 ] . strip ( ) <EOL> question = '<STR_LIT>' <EOL> skip = False <EOL> for letter in qtxt : <EOL> if letter == '<STR_LIT:<>' : <EOL> skip = True <EOL> if letter == '<STR_LIT:>>' : <EOL> skip = False <EOL> if skip : <EOL> continue <EOL> if letter . isalnum ( ) or letter == '<STR_LIT:U+0020>' : <EOL> if letter == '<STR_LIT:U+0020>' : <EOL> letter = '<STR_LIT:_>' <EOL> question += letter . lower ( ) <EOL> return question <EOL> f = open ( "<STR_LIT>" ) <EOL> q = open ( "<STR_LIT>" , "<STR_LIT:w>" ) <EOL> def write_answer ( q , question , answer ) : <EOL> q . write ( "<STR_LIT>" % question ) <EOL> question = process_question ( question ) <EOL> ans = open ( "<STR_LIT>" % question , "<STR_LIT:w>" ) <EOL> ans . write ( answer ) <EOL> ans . close ( ) <EOL> finding_h3 = True <EOL> reading_answer = False <EOL> read_already = False <EOL> while <NUM_LIT:1> : <EOL> if not read_already : <EOL> l = f . readline ( ) <EOL> print "<STR_LIT>" , l <EOL> if not l or l . find ( "<STR_LIT>" ) != - <NUM_LIT:1> : <EOL> if reading_answer : <EOL> write_answer ( q , question , answer ) <EOL> break <EOL> read_already = False <EOL> if finding_h3 : <EOL> h3 = l . find ( "<STR_LIT>" ) <EOL> if h3 == - <NUM_LIT:1> : <EOL> continue <EOL> print "<STR_LIT>" , h3 <EOL> endh3 = l . find ( "<STR_LIT>" ) <EOL> question = l [ h3 + <NUM_LIT:4> : endh3 ] . strip ( ) <EOL> reading_answer = True <EOL> finding_h3 = False <EOL> answer = '<STR_LIT>' <EOL> print "<STR_LIT>" <EOL> continue <EOL> elif reading_answer : <EOL> h3 = l . find ( "<STR_LIT>" ) <EOL> if h3 == - <NUM_LIT:1> : <EOL> answer += l <EOL> else : <EOL> read_already = True <EOL> reading_answer = False <EOL> finding_h3 = True <EOL> write_answer ( q , question , answer ) </s>
