Question: Part 4: Implementing the Solution in Python Summary In this final part of the course project, you will implement the solution in Python. Description Throughout
Part 4: Implementing the Solution in Python Summary In this final part of the course project, you will implement the solution in Python. Description Throughout this course project, we have been applying computational thinking to solve the problem of counting the number of occurrences of a word and its synonyms in a corpus of text documents. In Part 1, we applied the pillars of computational thinking to decompose this problem into two smaller problems, then used pattern recognition to find commonalities between the problems, used data representation and abstraction to identify the data we needed, and developed an algorithm. In Part 2, we represented that algorithm using a flowchart, and in Part 3 we developed the pseudocode for that algorithm as follows: Now, to finish the computational thinking problem solving process, implement this algorithm in Python in the space below by completing the search function. As you can see, the par ameter to the function is the keyword for which to search. Your program can also access two other variables that you will need to complete the program: Pic1 Thesaurus, which is a list of Entry objects; each Entry object has a word attribute, which is a string of characters; and an attribute called synonyms, which is a list of strings Corpus, which is a list of lists of strings For Pic 4 Your program will be evaluated using the inputs happy and sad for the Thesaurus and Corpus we have provided, along with other test inputs as well. Keep in mind that you can print out the Thesaurus and Corpus objects to see what is in them and to get an idea of whether your program is producing the correct output for those inputs. Hints Recall that using the computational thinking pillar of decomposition, we broke this problem into two small problems: finding the synonyms and counting the number of occurrences for each word. Rather than writing the entire function all at once, start on the first part (finding the synonyms) and make sure that works before moving on to the second. Review previous activities and lessons for examples of iterating over lists, looking for individual values, and updating variables to keep count of something. Part of the challenge of this activity is knowing in advance whether your program is generating the correct output. As mentioned above, you can create your own Thesaurus and Corpus based on the examples described above, and use these to determine whether your program is correctly finding the synonyms and correctly counting the number of occurrences; be sure to do this outside the function definition. Keep in mind, though, that your function will be graded using the Thesaurus and Corpus that we have provided. If youd like to see the Thesaurus and Corpus that we have provided, dont forget that these are varia

bles just like any others, and you can print out their values. As in previous activities, dont forget that you can use the print function to print out intermediate values as your code is performing operations so that you can see what is happening, and you can

use the Run button to run the program and see those outputs.

And the Corpus variable may be defined like this: Each document is represented as a list of words, which are all low Corpus is a list containing those lists. You can access the Thesaurus and Corpus variables in vour proc For example, the Entry class and Thesaurus variable may be defined like this: \begin{tabular}{|l|c} 1 & class Entry: \\ 2 & def init__(self, input_word, input_synonyms) : \\ 3 & self.word = input_word \\ 4 & self.synonyms = input_synonyms \\ 5 & \\ 6 & e1= Entry("dog", ["doggie", "puppy"]) \\ 7 & e2= Entry("cat", ["kitty"]) \\ 8 & \\ 9 & Thesaurus = [e1, e2] \end{tabular} Note that the first argument to the Entry constructor is the word in the thesaurus, and t And the Corpus variable may be defined like this: Each document is represented as a list of words, which are all low Corpus is a list containing those lists. You can access the Thesaurus and Corpus variables in vour proc For example, the Entry class and Thesaurus variable may be defined like this: \begin{tabular}{|l|c} 1 & class Entry: \\ 2 & def init__(self, input_word, input_synonyms) : \\ 3 & self.word = input_word \\ 4 & self.synonyms = input_synonyms \\ 5 & \\ 6 & e1= Entry("dog", ["doggie", "puppy"]) \\ 7 & e2= Entry("cat", ["kitty"]) \\ 8 & \\ 9 & Thesaurus = [e1, e2] \end{tabular} Note that the first argument to the Entry constructor is the word in the thesaurus, and t
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
