Question

Python Help Please! This is a problem that I have been stuck on.I am only suppose to use the basic python coding principles, including for loops, if statements, elif statements, lists, counters, functions, nested statements, .read, .write, while, local variables or global variables, etc. Thank you! I am using python 3.4.1. ***( The bottom photo is a continuation of the first one)****

Problem statement For this program, you are to design and implement text search engine, similar to the one used in Google Ads. This text search engine is supposed to search for a phrase (called a query) in one or more .txt files Search engines usually have complicated search algorithms but in this project we will take a slightly simpler app user enters pet supplies, then the search will be successful, if the text file contains phrases such as roach. We will look for a phrase entered by a user in the same exact word order, e.g. if the discount pet supplies or pet supplies wholesale, but not for searches like pet bird supplies, supplies Captain America and pet, or pet food and art supplies ies. While the order of the words is important, e.g America Captain will give different results, the search text engine itself is not case sensitive, e.g Captain America and captain America are the same thing In addition, our search will be based on keywords only, which means that common words (also known as stop words) and punctuation symbols ( Stop words are common words that are considered uninformative from a query point of view, for example articles, determinants, pronouns. The list of stop words is provided to the program in the file called StopWords.csv (sample file is provided on Canvas). For example, if the user enters black and white, maybe gray?, and and is considered a stop word, then the actual query is ! ?) will be removed from both the documents and the query black white maybe gray. Finally, the entire query/phrase has to appear on one line in the search file in order for the search to be successful, i.e. if a file contains black white on one line and maybe gray on another line, the match is not counted Input The user will provide the following input to your program search phrase the number of files they want to search, with possible selections including a letter Y to indicate all files in the directory (you are given a function in proj2.py file that returns a list of filenames in the current directory- use it in your code) if a different letter was entered, then a user must enter an integer to signify the specific number of files to process o if the specific number of files is selected, then the user has to enter their - filenames The program is to handle invalid input and proceed only, if a valid data type and value are entered -the search phrase, after removing stop words and replacing punctuations with blanks, has to have at least two letters and consist only of letters and whitespaces the number of files to search cannot be <= 0 and ca n not be more than the number of files in the directory the filename entered by the user must be the proper filename in the directory and must end in txt (filenames are case sensitive) ● - You may assume that the directory contains at least one .txt file Output The output is to show the search phrase, filenames, and the number of occurrences of search phrase in each file Sample run User input is shown in bold and italics Enter the phrase to search Thank you 123 Invalid entry try again Enter the phrase to search Thank you There are 2 txt files in this directory Type Y to search all the txt files in the current foldern How many files do you want to search in? 5 Invalid entry try again How many files dlo you wantto search in? 2 Enter the file name with extension: thank you. csv We can only search in .txt files which already exist Enter the file name with extension al. txt Enter the file name with extension: thank you. txt File al.txt has ooccurrences of the phrase Thank you File thank y u.txt has 5。ccurrences f the phrase Thank y u Do you want to search again? Say Y to continue searching: r Enter the phrase to search Thank and you There are 2 .txt files in this directory Type Y to search all the txt files in the current folder Y File al.txt has 0 occurrences of the phrase Thank you File thank you.txt has 5 occurrences of the phrase Thank you Do you want to search again? Say Y to continue searching: n

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 9 more requests to produce the answer.

1 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
Python Help Please! This is a problem that I have been stuck on.I am only suppose...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • Please help with this linux lab. Please include screenshots as I keep getting errors when I...

    Please help with this linux lab. Please include screenshots as I keep getting errors when I attempt this lab. Thank you in advance Example 1 Enter the system root directory cd / pwd [this command prints working directory] Here is how to go back to your home directory: cd ~ pwd Example 2 Use the Change directory command cd /labs/lab1/ohio inside the ohio folder use the Touch command to create a file called ohiostate.txt /labs/lab1/ohio/touch ohiostate.txt Use the pwd and...

  • Hello, I am attempting to write a basic shell script using bash. It will need to...

    Hello, I am attempting to write a basic shell script using bash. It will need to print the user, host, time, and date. It will need to take user input for a txt file to be searched and create a new file to save the results. It must print the number of lines and characters in the text. The user will need to enter three words to be searched, and the number of occurrences of those words in the text...

  • JAVA Primitive Editor (Please help, I am stuck on this assignment which is worth a lot...

    JAVA Primitive Editor (Please help, I am stuck on this assignment which is worth a lot of points. Make sure that the program works because I had someone answer this incorrectly!) The primary goal of the assignment is to develop a Java based primitive editor. We all know what an editor of a text file is. Notepad, Wordpad, TextWrangler, Pages, and Word are all text editors, where you can type text, correct the text in various places by moving the...

  • Python program This assignment requires you to write a single large program. I have broken it...

    Python program This assignment requires you to write a single large program. I have broken it into two parts below as a suggestion for how to approach writing the code. Please turn in one program file. Sentiment Analysis is a Big Data problem which seeks to determine the general attitude of a writer given some text they have written. For instance, we would like to have a program that could look at the text "The film was a breath of...

  • Using Ubuntu OS... help is greatly needed! Thank you. Create an alias called "home" that does...

    Using Ubuntu OS... help is greatly needed! Thank you. Create an alias called "home" that does two things... returns you to your home directory, then does a long listing of all files found there Create a file called "Output.txt" that contains the output of the "ls /etc" command Using "cat", create a file called "poem.txt" where you enter at least one line of text ("Mary had a little lamb" will do...) Using "cat", pipe the contents of poem.txt into the...

  • could you please help me with this problem, also I need a little text so I...

    could you please help me with this problem, also I need a little text so I can understand how you solved the problem? import java.io.File; import java.util.Scanner; /** * This program lists the files in a directory specified by * the user. The user is asked to type in a directory name. * If the name entered by the user is not a directory, a * message is printed and the program ends. */ public class DirectoryList { public static...

  • please help in python Suppose you have been tasked to write a Python program that will...

    please help in python Suppose you have been tasked to write a Python program that will accomplish the following tasks as related to the daily gas prices for the past year (365 days): • display the five (5) lowest gas prices for the year • display the five (5) highest gas prices for the year • allow the user to search for a specific gas price in the list; you should display a message for whether or not you found...

  • I am working on Exercise 5.8 from Fundamentals of Python 2nd edition. Do you have a...

    I am working on Exercise 5.8 from Fundamentals of Python 2nd edition. Do you have a solution for this item? Thank you. Here is the code I have. I just need 1 instance of each to show in my output. should look like: AM 3 I 3 SAM 3 Thank you... # Put your code here #fileName = input("Enter the file name: ") fileName = "example.txt" #fileName = "kgtest.txt" inputFile = open(fileName, 'r') text = inputFile.read() #print(text) words = text.split()...

  • NEED HELP with HTML with Javascript embedding for form validation project below. I have my code...

    NEED HELP with HTML with Javascript embedding for form validation project below. I have my code below but I'm stuck with validation. If anyone can fix it, I'd really appreciate. ****************************************************************************** CODE: <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html> <head> <title>Nice</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script> var textFromTextArea; function getWords(){ var text =...

  • Your mission in this programming assignment is to create a Python program that will take an...

    Your mission in this programming assignment is to create a Python program that will take an input file, determine if the contents of the file contain email addresses and/or phone numbers, create an output file with any found email addresses and phone numbers, and then create an archive with the output file as its contents.   Tasks Your program is to accomplish the following: ‐ Welcome the user to the program ‐ Prompt for and get an input filename, a .txt...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT