Assume I have a very long text and I'd like to extract a certain length of context around a specific word. For example in the following text I'd like to extract 8 words around the word warrior.
........
........
... died. He was a very brave warrior, fighting for freedom against the odds ...
........
........
In this case the result would be
He was a very brave warrior, fighting for freedom
Notice how I dropped the word died as I'd prefer starting from the beginning of a full sentence and how I extracted more than just 8 words because fight for freedom
is much more meaningful than just fighting for.
Are there any algorithms, or research conducted in this field that I could follow? How should I go about approaching this problem.