Th: command not found error while preprocessing

I have been trying to preprocess the source-target data to train a model to translate in a new language.
!th preprocess.lua -train_src data/src-train.txt -train_tgt data/tgt-train.txt -valid_src data/src-val.txt -valid_tgt data/tgt-val.txt -save_data data/demo

However, I have been constantly getting the command not found error. I installed the dependencies for the th command, and while the command works in the torch interactive session, it is still unrecognized outside that.

I followed this installation process too and while the first script runs successfully, the second script provided does not.

I also tried adding th to the path variables but didn’t work.

The Lua version is deprecated. You should either use OpenNMT-py or OpenNMT-tf.