def sentence_to_ids(sentence, word2id, padded_len, end_symbol, padding_symbol):
    """ Converts a sequence of symbols to a padded sequence of their ids.

      sentence: a string, input/output sequence of symbols.
      word2id: a dict, a mapping from original symbols to ids.
      padded_len: an integer, a desirable length of the sequence.

      result: a tuple of (a list of ids, an actual length of sentence).
    """

    sent_len = len(sentence) + 1
    sent_ids = [word2id[w] for w in sentence[:padded_len - 1]
                ] + [word2id[end_symbol]] + [word2id[padding_symbol]] * (padded_len - sent_len)

    return sent_ids, min(len(sent_ids), sent_len)