<s> if __name__ == "<STR_LIT:__main__>" : <EOL> with open ( "<STR_LIT>" , "<STR_LIT:w>" ) as logout , open ( "<STR_LIT>" ) as f , open ( "<STR_LIT>" , "<STR_LIT:w>" ) as fout , open ( "<STR_LIT>" ) as log : <EOL> content2id = { } <EOL> id2word = { } <EOL> for l in log : <EOL> word , word_number , topic_number , content_id , _ = l . strip ( ) . split ( ) <EOL> word_number = int ( word_number ) <EOL> topic_number = int ( topic_number ) <EOL> content_id = int ( content_id ) <EOL> content2id [ ( word_number , topic_number ) ] = content_id <EOL> id2word [ word_number ] = word <EOL> print "<STR_LIT>" <EOL> for ( line_num , l ) in enumerate ( f ) : <EOL> word1 , topic1 , word2 , topic2 , score = l . strip ( ) . split ( ) <EOL> word1 = int ( word1 ) <EOL> topic1 = int ( topic1 ) <EOL> word2 = int ( word2 ) <EOL> topic2 = int ( topic2 ) <EOL> try : <EOL> content1 = content2id [ ( word1 , topic1 ) ] <EOL> content2 = content2id [ ( word2 , topic2 ) ] <EOL> except : <EOL> print line_num <EOL> continue <EOL> print >> fout , content1 , content2 , score <EOL> print >> logout , id2word [ word1 ] , id2word [ word2 ] </s>
