def text_to_sequence(self, text, reverse=False, padding='post', truncating='post'):
    if self.lower:
        text = text.lower()
    words = text.split()
    unknownidx = (len(self.word2idx) + 1)
    sequence = [(self.word2idx[w] if (w in self.word2idx) else unknownidx) for w in words]
    if (len(sequence) == 0):
        sequence = [0]
    if reverse:
        sequence = sequence[::(- 1)]
    return pad_and_truncate(sequence, self.max_seq_len, padding=padding, truncating=truncating)
def text_to_sequence(self, text, reverse=False, padding='post', truncating='post'):
    if self.lower:
        text = text.lower()
    words = text.split()
    unknownidx = (len(self.word2idx) + 1)
    sequence = [(self.word2idx[w] if (w in self.word2idx) else unknownidx) for w in words]
    if (len(sequence) == 0):
        sequence = [0]
    if reverse:
        sequence = sequence[::(- 1)]
    return pad_and_truncate(sequence, self.max_seq_len, padding=padding, truncating=truncating)