How to compose each word in the dataframe into a sentence, and generate the next sentence after the period or a question mark?
the original dataframe looks like this:
start_time end_time words
0.1 0.2 I
0.3 0.4 AM
0.5 0.6 GOOD.
0.7 0.8 HOW
0.9 1.0 ABOUT
1.1 1.2 YOU?
1.3 1.4 OK!
the result I want to get looks like this:
start_time end_time words
0.1 0.6 I AM GOOD.
0.7 1.2 HOW ABOUT YOU?
1.3 1.4 OK!
This is my dataframe:
data = {'start_time': [0.1, 0.3, 0.5, 0.7, 0.9, 1.1, 1.3],
'end_time': [0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4],
'word':['I','AM','OK.','HOW', 'ABOUT', 'YOU?','OK!']}
df = pd.DataFrame(data, columns = ['start_time', 'end_time','word'])
Is there any suggested algorithm to help this problem, thank you very much!