torchtext is the go to library to deal with text data, where we define Fields(how you want to deal your text data (tokenization etc.,)) and using vocab function of Fields, we can build mapping from text to intezers.
One hot encoding is one of the approaches to convert text data into intezers, with this approach if you encounter any text which you haven’t seen while fitting your train data, it assigns zero to all unseen variables by default.
However, word embeddings are advanced than one hot encoding approach. With Torchtext  field class allows to specify special tokens (the  unk_token  for out-of-vocabulary words, the  pad_token  for padding, the  eos_token  for the end of a sentence, and an optional  init_token  for the start of the sentence),
Please go through this tutorial, which gives a deeper understanding of how text data can be dealt using torch text. https://mlexplained.com/2018/02/08/a-comprehensive-tutorial-to-torchtext/ 9
Hope this answers your question
Thanks,
Sai