Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

USE PYTHON PLEASE AND FOLLOW THE RULES! Problem 1 (Text Analysis) Create a Python file called analysis.py that will perform text analysis on files. For

USE PYTHON PLEASE AND FOLLOW THE RULES!image text in transcribedimage text in transcribed

Problem 1 (Text Analysis) Create a Python file called analysis.py that will perform text analysis on files. For this question, assume that each space in the document separates one word from the next so any use of the term 'word' means a string that occurs between two spaces (or in two special cases, between the start of the file and a space, or between a space and the end of the file). You can also assume there is no punctuation or other symbols present in the files only words separated by spaces. If you want to see examples of the type of text, look in the testfile .txt files included on cuLearn. You must implement and test the following functions inside of your analysis.py file 1) load(str) Takes a single string argument, representing a filename. The program must open the file and parse the text inside. This function should initialize the variables (e.g., lists, dictionaries, other variables) you need to solve the remainder of the problem. This way, the file contents can be parsed once and the functions below can be executed many times without re-reading the file, which is a slow process This function should also remove any information stored from a previous file when it is called (i.e., you start from nothing every time load is called) 2) commonword(list) -Takes a single list-type argument which contains string values. The function should operate as follows: a. If the list is empty or none of the words specified in the list occur in the text that has been loaded, the function should return None b. Otherwise, the function should return the word contained in the list that occurs most often in the loaded text or any one of the most common, in the case of a tie 3) commonletter(list) Takes a single list-type argument which contains single character strings (i.e., etters/characters). The function should operate as follows: a. If the list is empty or none of the letters specified in the list occur in the text that has been loaded, the function should return None

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

AWS Certified Database Study Guide Specialty DBS-C01 Exam

Authors: Matheus Arrais, Rene Martinez Bravet, Leonardo Ciccone, Angie Nobre Cocharero, Erika Kurauchi, Hugo Rozestraten

1st Edition

1119778956, 978-1119778950

More Books

Students also viewed these Databases questions

Question

How to reverse a Armstrong number by using double linked list ?

Answered: 1 week ago

Question

1. Which position would you take?

Answered: 1 week ago