Create a python file called analysis

Assignment Help Basic Computer Science
Reference no: EM131716217

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., letters/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. COMP 1005/1405 - S17 - A5 Due Tuesday, June 13 at 11:55 PM 2 b. Otherwise, the function should return the letter 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.

4) commonpair(str) - Takes a single string argument, representing the first word. This function should return the word that most frequently followed the given argument word (or one of, in case of ties). If the argument word does not appear in the text at all, or is never followed by another word (i.e., is the last word in the file), this function should return None.

5) countall() - Returns the total number of words found in the text that has been loaded. That is, the word count of the document.

6) countunique() - Returns the number of unique words in the text that has been loaded. This is different than the previous function, as it should not count the same word more than once. You can use the analysistester.py file from cuLearn, along with the posted text files, to test your functions. You can also create additional text files of your own to further test the correctness of your program. If you want an easy way to find out the necessary information about a file you created, you can copy/paste the contents into the form at https://textalyser.net. It can give you the total word count, unique word count, word frequency to determine the most common word, and common word pairs.

Use python pls. i'm currently using python 3.6.2

Reference no: EM131716217

Questions Cloud

Single function called cachedfactorial : (Recursive Factorial) Create a Python file called factorial.py that a single function called cachedfactorial.
Describe the two active processes of cell membrane transport : Describe the two active processes of cell membrane transport, state their energy requirements, and provide examples of substances transported by these methods
Which key performance indicator is the most important kpi : In your opinion, which Key Performance Indicator is the most important KPI for supply chain success and the business success of the organization?
Describe the patients personal and medical history : Reflect on a Pregnant patient who presented with a Gastrointestinal disorder - Describe the patients personal and medical history
Create a python file called analysis : Problem 1 (Text Analysis) create a Python file called analysis.py that will perform text analysis on files.
Determine that boxplot find all the outliers : For the values 1, 2, 3, 4, 5, 6, 7, 8, 9, and 10 there are no outliers. If you increase 10 to 20, then 20 would be declared an outlier by a boxplot.
Examine principal way in which leadership of ncaa contribute : Examine the principal ways in which the leadership of the NCAA contributed to the ethical violations of Penn State, Ohio State, and the University of Arkansas.
Calculate the cost per equivalent unit for direct materials : Callahan Company uses the weighted-average method in its process costing system. The cost per equivalent unit for direct materials is
Convert between temperatures in fahrenheit : Write a Python application that allows the user to convert between temperatures in fahrenheit and temperatures in celsius.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Determine the keys and the functional dependencies

It is left to you to determine the keys and the functional dependencies. There will also be some minor work required to convert the tables into third normal form (3NF).

  Traditional way of accomplishing the same thing

1. Write a UNIX command line that will print the number of processes that root has running on this machine. This uses pipes and is tricky. Test your answer! 2. Create a file called answers and give the following command: $ > answers.txt

  Determining asymptotic formula for recurrence equations

Give an asymptotic formula for each of the recurrence equations given below, using big "Θ" rather than just big "O" for better results when possible.

  Start with an entry point for the service

Use the case study material as a requirement. We will concentrate improving services that were built in project 3 by adding the following:

  What is the most likely cause of the problem

Some time later, Leo calls you back to tell you that while he is able to access the Trinity folder and read the files stored there, he has been unable to save changes back to the server. What is the most likely cause of the problem?

  Key concept in information systems

Use the Internet or the Strayer Library to research one (1) concept in information systems that you have studied in this course. You may select a topic of your choice or you may use one (1) of the following:

  What is the difference between data and information

What is the difference between Data and Information? Provide some specific examples of how organizations utilize data and information. Please provide reference.

  Connecting your computer to public networks

Prepare a flyer that lists specific steps that customers can take to protect their data when surfing on publicly accessible networks.

  What positions might be more difficult to outsource

What are some types of positions that easily can be outsourced? What positions might be more difficult to outsource? Why

  Short description css

Select two pages where you have applied CSS. Then create two external style sheets and apply each to the two copies of the page. Then answer the following questions below

  Island that will be developed off dubai

"Square Isle is a new island that will be developed off Dubai. It will measure 20km long by 20km wide.

  Factors of resistance to change

Describe the organizational factors that create stress and discuss how they compare to the factors of resistance to change. How are they similar and different? Are the methods for managing change useful for managing stress caused by organizational..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd