Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Python 3 (long explanation but shouldn't be hard!) ** This function should read any downloaded .txt file from https://www.folgerdigitaltexts.org/download/ Write the function dictionary(fn) that,

In Python 3 (long explanation but shouldn't be hard!)

** This function should read any downloaded .txt file from https://www.folgerdigitaltexts.org/download/

Write the function dictionary(fn) that, given the filename fn of a Shakespeare play from Folger Digital Texts, builds and returns a Python dictionary that records, for each character, the number of speeches of the character, the act of the first speech of the character, and the scene of the first speech of the character. The keys of the dictionary are character names, where a character name is defined as the first words listed for a character (e.g., BOTTOM). The value associated with this key is a list of 3 integers. The dictionary entry for Juliet in Romeo and Juliet should be 'JULIET': [118, 1, 3] since Juliet first speaks in Act 1, Scene 3 and has 118 speeches in the play. If a character speaks that is not in the list of characters of the play (e.g., CITIZENS in Romeo and Juliet), simply ignore it (no dictionary entry). If a character never speaks (e.g., CHORUS in Romeo and Juliet), you should still have a dictionary entry for this character, and simply set its act and scene to 0: 'CHORUS' : [0, 0, 0]. The first speech is defined by the act and scene that the character first speaks , not the first time they are mentioned. You may assume that act and scene are recorded as in the Folger Digital Texts: (e.g., ACT 1, Scene 1). You may assume that the words ACT and Scene only occur at the beginning of a line when they are recording an act or scene. You may assume that acts and scenes begin at 1 and increase by 1 each time. A character is defined as a character in capital letters in the section called Characters in the Play. When a character speaks, later in the play, their name is listed in all-caps at the beginning of the line. I have edited the text so that the first name in the list of characters is always the same as the name used later in the play to refer to that characters speech. In particular, there are two types of change: 1) if a character has two names and the text uses both names, these names are combined into one (FRIAR LAWRENCE becomes FRIARLAWRENCE). 2) if a character has two names and only one is used (e.g., NICK BOTTOM uses BOTTOM), I have placed the name that is used first . For example, BOTTOM, NICK. Or QUINCE, PETER. Please include your algorithm in the docstring of the dictionary(fn) function. You should write other functions to divide and conquer your solution: please include docstrings for every function that you add

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

1 2 3 Data Base Techniques

Authors: Dick Andersen

1st Edition

0880223464, 978-0880223461

More Books

Students also viewed these Databases questions

Question

Question How are VEBA assets allocated when a plan terminates?

Answered: 1 week ago

Question

Question May a taxpayer roll over money from an IRA to an HSA?

Answered: 1 week ago

Question

Question What is the doughnut hole in HSA coverage?

Answered: 1 week ago