Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Structure Of The Relational Database Model

Authors: Jan Paredaens ,Paul De Bra ,Marc Gyssens ,Dirk Van Gucht

1st Edition

3642699588, 978-3642699580

More Books

Students also viewed these Databases questions