Aug-30-2022, 06:52 AM
I want to find ALL instances of asked questions and the persons who asked them in the below text.
++++++++++++++++
26 Mr Kwek Hian Chuan Henry asked the Minister for the Environment and Water Resources whether Singapore will stay the course on fighting climate change and meet our climate change commitments despite the current upheavals in the energy market and the potential long-term economic impact arising from the COVID-19 situation. We agree with the Panel and will instead strengthen regulations to safeguard the safety of path users. With regard to Ms Rahayu Mahzam's suggestion of tapping on the Small Claims Tribunal for personal injury claims up to $20,000, we understand that the Tribunal does not hear personal injury claims. Mr Gan Thiam Poh, Ms Rahayu Mahzam and Mr Melvin Yong have asked about online retailers of PMDs. Mr Melvin Yong asked about the qualifications and training of OEOs.
++++++++++++++++++++++++++
Desired Output:
asked= ["Mr Kwek Hian Chuan Henry asked the Minister for the Environment and Water Resources whether Singapore will stay the course on fighting climate change and meet our climate change commitments despite the current upheavals in the energy market and the potential long-term economic impact arising from the COVID-19 situation." ,
"Mr Gan Thiam Poh, Ms Rahayu Mahzam and Mr Melvin Yong have asked about online retailers of PMDs.",
"Mr Melvin Yong asked about the qualifications and training of OEOs."]
askedperson= ["Mr Kwek Hian Chuan Henry", "Mr Gan Thiam Poh, Ms Rahayu Mahzam and Mr Melvin Yong", "Mr Melvin Yong" ]
My Code which doesn't work:
But the odd thing is that when I used search, I could correctly obtain the 1st match
++++++++++++++++
26 Mr Kwek Hian Chuan Henry asked the Minister for the Environment and Water Resources whether Singapore will stay the course on fighting climate change and meet our climate change commitments despite the current upheavals in the energy market and the potential long-term economic impact arising from the COVID-19 situation. We agree with the Panel and will instead strengthen regulations to safeguard the safety of path users. With regard to Ms Rahayu Mahzam's suggestion of tapping on the Small Claims Tribunal for personal injury claims up to $20,000, we understand that the Tribunal does not hear personal injury claims. Mr Gan Thiam Poh, Ms Rahayu Mahzam and Mr Melvin Yong have asked about online retailers of PMDs. Mr Melvin Yong asked about the qualifications and training of OEOs.
++++++++++++++++++++++++++
Desired Output:
asked= ["Mr Kwek Hian Chuan Henry asked the Minister for the Environment and Water Resources whether Singapore will stay the course on fighting climate change and meet our climate change commitments despite the current upheavals in the energy market and the potential long-term economic impact arising from the COVID-19 situation." ,
"Mr Gan Thiam Poh, Ms Rahayu Mahzam and Mr Melvin Yong have asked about online retailers of PMDs.",
"Mr Melvin Yong asked about the qualifications and training of OEOs."]
askedperson= ["Mr Kwek Hian Chuan Henry", "Mr Gan Thiam Poh, Ms Rahayu Mahzam and Mr Melvin Yong", "Mr Melvin Yong" ]
My Code which doesn't work:
1 2 3 4 5 6 7 8 9 10 11 12 |
asked_regex = re. compile (r '(Mr|Miss|Ms|Dr)(.|\n)+?(asked)(.|\n)+?\.' ) asked = re.findall(asked_regex, text_list) askedperson_regex = re. compile (r '(Mr|Miss|Ms|Dr)(.|\n)+?(?=asked)' ) askedperson = re.findall(askedperson_regex, text_list) print (asked) [( 'Mr' , ' ' , 'asked' , 'n' ), ( 'Ms' , ' ' , 'asked' , 's' ), ( 'Mr' , ' ' , 'asked' , 's' )] print (askedperson) [( 'Mr' , ' ' ), ( 'Ms' , ' ' ), ( 'Mr' , ' ' )] |
1 2 3 4 5 6 |
asked_regex = re. compile (r '(Mr|Miss|Ms|Dr)(.|\n)+?(asked)(.|\n)+?\.' ) asked = asked_regex.search(text_list).group().strip() print (asked) 26 Mr Kwek Hian Chuan Henry asked the Minister for the Environment and Water Resources whether Singapore will stay the course on fighting climate change and meet our climate change commitments despite the current upheavals in the energy market and the potential long - term economic impact arising from the COVID - 19 situation. |