Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON: Please help with Part 2! *** Part 1 and Part 2 listed below first iteration of Part 2 for further explanation of the program.

PYTHON: Please help with Part 2! *** Part 1 and Part 2 listed below first iteration of Part 2 for further explanation of the program. I have Part 1 figured out***

Part 2: Define the search() function to find the word occurrences

The search() function accepts two parameters, a String and a List, and performs the following tasks:

Opens the search file using the filename specified by the String parameter

Reads the contents from the search file

Closes the search file

Converts all characters read from the search file to lower case and removes any punctuation

Look through each line of the search file, find occurrences of each word from the parameter List.

Store each word and the line numbers where they are found in a new word occurrences List

Return the word occurrences List

.

.

.

.

.

Part 1: Define the words() function to read a List of words

The words() function accepts one parameter, a String, and performs the following tasks:

Opens the words file using the filename specified by the String parameter

Reads the contents from the words file into a new List of words

Closes the words file

Converts all words in the List to lower case and removes any punctuation characters including: !()-[]{};:'"\,<>./?@#$%^&*_~

Returns the List of Words

Part 2: Define the search() function to find the word occurrences

The search() function accepts two parameters, a String and a List, and performs the following tasks:

Opens the search file using the filename specified by the String parameter

Reads the contents from the search file

Closes the search file

Converts all characters read from the search file to lower case and removes any punctuation

Look through each line of the search file, find occurrences of each word from the parameter List.

Store each word and the line numbers where they are found in a new word occurrences List

Return the word occurrences List

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_2

Step: 3

blur-text-image_3

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

Database Design Application Development And Administration

Authors: Michael V. Mannino

3rd Edition

0071107010, 978-0071107013

More Books

Students also viewed these Databases questions

Question

=+4 What are non-union workers representations?

Answered: 1 week ago