'Returns:
query = tensor (vector) of token indices for query
query_length = length of query
memory = tensor (matrix) where each row contains token indices for a memory
memory_lengths = tensor (vector) with lengths of each memory'

def parse(self, text):

    sp = text.split('\n')
    query_sentence = sp[(-1)]
    query = self.dict.txt2vec(query_sentence)
    query = torch.LongTensor(query)
    query_length = torch.LongTensor([len(query)])
    sp = sp[:(-1)]
    sentences = []
    for s in sp:
        sentences.extend(s.split(' DCTB '))
    if (len(sentences) == 0):
        sentences.append(self.dict.null_token)
    num_mems = min(self.mem_size, len(sentences))
    memory_sentences = sentences[(- num_mems):]
    memory = [self.dict.txt2vec(s) for s in memory_sentences]
    memory = [torch.LongTensor(m) for m in memory]
    memory_lengths = torch.LongTensor([len(m) for m in memory])
    memory = torch.cat(memory)
    return (query, memory, query_length, memory_lengths)
