Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 Without changing any preset code, and onnly adding between #code starts here and # code ends here.
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
data processscenesactscenetexts
dataACT ISCENE :
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started