I am trying to extract sentences from a text, by using Python. Every word in the text are written in a line with additional info related to that word:
Mary Noun Name
loves Verb No-Name
John Noun Name
. Punct No-Name
The sentence boundaries are marked with an empty line. I want to extract the whole sentence that contains words with some particular feature (e.g. sentences with names).
Util now, I have only managed to extract the word of interest, and not the whole sentence.
I use .readlines()
to read the text line by line. I then loop through the lines and use re and .split('\t')
to split the lines, so that every line is represented by a list of 3 elements. I then match the element in the list with the desired value, and can extract the related word, but I can not figure out how I can extract the whole sentence..
Anyone have some advice?