Question: In python 3, Write a function: Params: fn (string) filename of a Shakespeare play, downloaded from Folger Digital Texts in txt (http://www.folgerdigitaltexts.org/download/) Returns: (dict) key

In python 3,

Write a function:

Params: fn (string) filename of a Shakespeare play,

downloaded from Folger Digital Texts in txt (http://www.folgerdigitaltexts.org/download/)

Returns: (dict) key = character; value = [nSpeech, act, scene], where

character := 1st word listed for a character (e.g., BOTTOM)

nSpeech := # speeches by the character;

act/scene := act and scene of the character's first words

so each key is a string and each value is [int, int, int] list

Following helper function was provided to remove punctuation:

def punctuation(n):

return s.translate(str.maketrans({c:None for c in string.punctuation}))

Example output for Romeo and Juliet

{'PETRUCHIO': [1, 3, 1], 'GREGORY': [15, 1, 1], 'FRIARJOHN': [4, 5, 2], 'LADYCAPULET': [45, 1, 1], 'CAPULET': [50, 1, 1], 'ROMEO': [163, 1, 1], 'SAMPSON': [20, 1, 1], 'PETER': [13, 2, 4], 'JULIET': [118, 1, 3], 'ESCALUS': [0, 0, 0], 'NURSE': [90, 1, 3], 'TYBALT': [17, 1, 1], 'BENVOLIO': [63, 1, 1], 'ABRAM': [5, 1, 1], 'MONTAGUE': [10, 1, 1], 'BALTHASAR': [12, 5, 1], 'LADYMONTAGUE': [2, 1, 1], 'APOTHECARY': [4, 5, 1], 'PARIS': [23, 1, 2], 'FRIARLAWRENCE': [55, 2, 3], 'MERCUTIO': [62, 1, 4], 'CHORUS': [0, 0, 0]}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!