Refactor get_sentence_ids