How to detect the begin word and end word in a sentence with machine learning
For this kind of problem, you can study some of the latest research areas of reading comprehension in which people are trying to predict the starting index of the answer &amp; with the help that index they are predicting ending index of the answer.

Following screenshot took from BiDaF research paper
Refer to BiDaF for more details