Question: Complete the process _ scenes function to separate lines in scene _ text by , separate speakers from the beginnings of their speeches ( using
Complete the processscenes function to separate lines in scenetext by
separate speakers from the beginnings of their speeches using regex and collect the multiline speeches in a single string. Each speakerline pair should be stored in the defaultdict structure set up in the code below. Store each speakerline pair as a list. Process actscenetexts with processscenes, and print the first five lines of ACT I, SCENE
With the preset code:
from collections import defaultdict
def processscenesactscenetexts:
data defaultdictlambda : defaultdictlist
currentact, currentscene
## set dictionary keys
for actscene, scenetext in zipactscenetexts:: actscenetexts:::
if actscene: "ACT": # if it's a new act, update the currentact value
#your code starts hereseparate and collect the actscene information
#your code stops here
else:# otherwise assign the actsceneheading
#your code sarts herejust update the currentscene
#your code stops here
speaker, speech
for line in scenetext.split
:
#Your code starts here
#Your code stops here
return data
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
