(babi_file)
return [(BABI.flatten(_story), _question, answer) for _story, _question, answer in data]
Parse bAbI data into stories, queries, and answers.

        Arguments:
            babi_data (string): String of bAbI data.
            babi_file (string): Filename with bAbI data.

        Returns:
            list of tuples : List of (story, query, answer) words.
Parse bAbI data into stories, queries, and answers.
Parse bAbI data into stories queries and answers .
def parse_babi(babi_file):
        """
        Parse bAbI data into stories, queries, and answers.

        Arguments:
            babi_data (string): String of bAbI data.
            babi_file (string): Filename with bAbI data.

        Returns:
            list of tuples : List of (story, query, answer) words.
        """
        babi_data = open(babi_file).read()
        lines = BABI.data_to_list(babi_data)

        data, story = [], []
        for line in lines:
            nid, line = line.split(' ', 1)
            if int(nid) == 1:
                story = []
            if '\t' in line:
                q, a, supporting = line.split('\t')
                substory = [x for x in story if x]
                data.append((substory, BABI.tokenize(q), a))
                story.append('')
            else:
                sent = BABI.tokenize(line)
                story.append(sent)

        return [(BABI.flatten(_story), _question, answer) for _story, _question, answer in data]
def parse_babi ( babi_file ) : babi_data = open ( babi_file ) . read ( ) lines = BABI . data_to_list ( babi_data ) data , story = [ ] , [ ] for line in lines : nid , line = line . split ( ' ' , 1 ) if int ( nid ) == 1 : story = [ ] if '\t' in line : q , a , supporting = line . split ( '\t' ) substory = [ x for x in story if x ] data . append ( ( substory , BABI . tokenize ( q ) , a ) ) story . append ( '' ) else : sent = BABI . tokenize ( line ) story . append ( sent ) return [ ( BABI . flatten ( _story ) , _question , answer ) for _story , _question , answer in data ]