<s> import numpy as np <EOL> import cPickle as pickle <EOL> import decoder <EOL> def main ( in_file , char_file , ali_file , num_to_print , lm_file = None ) : <EOL> with open ( in_file , '<STR_LIT:r>' ) as f : <EOL> ll_dict = pickle . load ( f ) <EOL> with open ( char_file , '<STR_LIT:r>' ) as f : <EOL> phone_list = map ( lambda x : x . rstrip ( ) . split ( ) [ <NUM_LIT:0> ] , f . readlines ( ) ) <EOL> phone_list . insert ( <NUM_LIT:0> , '<STR_LIT:_>' ) <EOL> with open ( ali_file , '<STR_LIT:r>' ) as f : <EOL> ali_dict = { } <EOL> for l in f . readlines ( ) : <EOL> l_split = l . rstrip ( ) . split ( ) <EOL> ali_dict [ l_split [ <NUM_LIT:0> ] ] = '<STR_LIT>' . join ( [ phone_list [ int ( x ) ] for x in l_split [ <NUM_LIT:1> : ] ] ) <EOL> dec_argmax = decoder . ArgmaxDecoder ( ) <EOL> dec_argmax . load_chars ( char_file ) <EOL> dec_lm = decoder . BeamLMDecoder ( ) <EOL> dec_lm . load_chars ( char_file ) <EOL> dec_lm . load_lm ( lm_file ) <EOL> n_printed = <NUM_LIT:0> <EOL> for i , k in enumerate ( ll_dict ) : <EOL> hyp_argmax , score_argmax = dec_argmax . decode ( ll_dict [ k ] . astype ( np . double ) ) <EOL> print score_argmax , hyp_argmax <EOL> hyp_lm , score_lm = dec_lm . decode ( ll_dict [ k ] . astype ( np . double ) ) <EOL> print score_lm , hyp_lm <EOL> print ali_dict [ k ] <EOL> n_printed += <NUM_LIT:1> <EOL> if n_printed >= num_to_print : <EOL> break <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> ll_path = '<STR_LIT>' <EOL> in_file = ll_path + '<STR_LIT>' <EOL> char_file = ll_path + '<STR_LIT>' <EOL> ali_file = ll_path + '<STR_LIT>' <EOL> lm_file = '<STR_LIT>' <EOL> main ( in_file , char_file , ali_file , <NUM_LIT:10> , lm_file = lm_file ) </s>
