()
return questions, answers
Generate some news data
Generate some news data
Generate some news data
def generate_news_data():
    """Generate some news data"""
    print ("Generating Data")
    answers = open(NEWS_FILE_NAME_SPLIT).read().decode('utf-8').split("\n")
    questions = []
    print('shuffle', end=" ")
    random_shuffle(answers)
    print("Done")
    for answer_index, answer in enumerate(answers):
        question, answer = generate_question(answer)
        answers[answer_index] = answer
        assert len(answer) == CONFIG.max_input_len
        if random_randint(100000) == 8: # Show some progress
            print (len(answers))
            print ("answer:   '{}'".format(answer))
            print ("question: '{}'".format(question))
            print ()
        question = question[::-1] if CONFIG.inverted else question
        questions.append(question)

    return questions, answers
def generate_news_data ( ) : print ( "Generating Data" ) answers = open ( NEWS_FILE_NAME_SPLIT ) . read ( ) . decode ( 'utf-8' ) . split ( "\n" ) questions = [ ] print ( 'shuffle' , end = " " ) random_shuffle ( answers ) print ( "Done" ) for answer_index , answer in enumerate ( answers ) : question , answer = generate_question ( answer ) answers [ answer_index ] = answer assert len ( answer ) == CONFIG . max_input_len if random_randint ( 100000 ) == 8 : # Show some progress print ( len ( answers ) ) print ( "answer:   '{}'" . format ( answer ) ) print ( "question: '{}'" . format ( question ) ) print ( ) question = question [ : : - 1 ] if CONFIG . inverted else question questions . append ( question ) return questions , answers