'Reads data in the fbdialog format.
Returns ``((x,y,r,c), new_episode?)`` tuples.
``x`` represents a query, ``y`` represents the labels, ``r`` represents any reward,
and ``c`` represents any label_candidates.
The example above will be translated into the following tuples:
x: \'Sam went to the kitchen\nPat gave Sam the milk\nWhere is the milk?\'
y: [\'kitchen\']
r: \'1\'
c: [\'hallway\', \'kitchen\', \'bathroom\']
new_episode = True (this is the first example in the episode)
x: \'Sam went to the hallway\nPat went to the bathroom\nWhere is the
milk?\'
y: [\'hallway\']
r: \'1\'
c: [\'hallway\', \'kitchen\', \'bathroom\']
new_episode = False (this is the second example in the episode)'

def setup_data(self, path):

    print (('[loading    fbdialog    data:' + path) + ']')
    with open(path) as read:
        start = True
        x = ''
        reward = None
        dialog_index = 0
        for line in read:
            line = line.strip().replace('\\n', '\n')
            if (len(line) == 0):
                continue
            space_idx = line.find('    ')
            conv_id = line[:space_idx]
            split = line[(space_idx + 1):].split(' DCTB ')
            for i in range(len(split)):
                word = split[i].strip()
                if (len(word) == 0):
                    split[i] = ''
                else:
                    split[i] = word
            if ((len(split) > 2) and (split[2] == '')):
                split[2] = None
            if (conv_id == '1'):
                dialog_index += 1
                x = x.strip()
                if x:
                    (yield ([x, None, reward], start))
                start = True
                if self.cloze:
                    x = 'Fill    in    the    blank    in    the    last    sentence.\n{x}'.format(x=split[0])
                else:
                    x = split[0]
            elif x:
                x = '{x}\n{next_x}'.format(x=x, next_x=split[0])
            else:
                if (len(split) > 2):
                    reward = split[2]
                x = split[0]
            if ((len(split) > 1) and split[1]):
                split[0] = x
                split[1] = split[1].split('|')
                if (len(split) > 3):
                    split[3] = split[3].split('|')
                if start:
                    (yield (split, True))
                    start = False
                else:
                    (yield (split, False))
                x = ''
                reward = None
