Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please answer all parts in Python. Thank you. Problem 3. You are given the following text. In [ ]: text = It was dark, like
Please answer all parts in Python. Thank you.
Problem 3. You are given the following text. In [ ]: text = "It was dark, like the bottom of a well. There was a pattern of skulls and bones around I the frame, for the sake of appearances; Death could not look himself in the skull in a mirror I with cherubs and roses around it. The Death of Rats climbed the frame in a scrabble of claws and \ looked at Death expectantly from the top. Quoth fluttered over and pecked briefly at his own I reflection, on the basis that anything was worth a try. Show me, said Death, show me my thoughts. A chessboard appeared, but it was triangular, and so big that only the nearest point could be seen. Right on this point was the world - turtle, elephants, the little orbiting sun and all. It was the I Discworld, which existed only just this side of total improbability and, therefore, in border country. In border country the border gets crossed, and sometimes things creep into the universe that have I rather more on their mind than a better life for their children and a wonderful future in the I fruit picking and domestic service industries. On every other black or white triangle of the I chessboard, all the way to infinity, was a small grey shape, rather like an empty hooded robe." You are also given a string that contains all symbols of English alphabet. In [3]: alphabet = "abcdefghijklmnopqrstuvwxyz" Part 1. Write some code that generates the list unique_words, containing all and only the unique lowercase words from text. You should see the following output (the order can differ!): ['a', 'infinity', 'reflection', 'with', 'like', 'big', 'briefly', 'into', 'children', 'which', 'fruit', 'picking', 'ther e', 'try', 'little', 'around', 'appearances', 'appeared', 'all', 'crossed', 'basis', 'improbability', 'their', 'discworl d', 'black', 'to', 'death', 'future', 'only', 'my', 'robe', 'things', 'for', 'it', 'existed', 'said', 'sake', 'sometime s', 'right', 'way', 'that', 'country', 'chessboard', 'quoth', 'well', 'domestic', 'skull', 'wonderful', 'hooded', 'or', 'empty', 'bottom', 'mirror', 'himself', 'rather', 'over', 'every', 'triangle', 'roses', 'border', 'orbiting', 'was', 'fr om', 'show', 'be', 'pecked', 'bones', 'just', 'universe', 'me', 'triangular', 'gets', 'worth', 'have', 'climbed', 'servi ce', 'fluttered', 'top', 'but', 'grey', 'claws', 'at', 'rats', 'creep', 'own', 'pattern', 'point', 'white', 'than', 'dar k', 'therefore', 'frame', 'this', 'not', 'the', 'could', 'mind', 'turtle', 'scrabble', 'better', 'industries', 'looked', 'an', 'cherubs', 'life', 'anything', 'more', 'small', 'and', 'of', 'his', 'on', 'skulls', 'elephants', 'in', 'thoughts', 'seen', 'nearest', 'expectantly', 'other', 'side', 'shape', 'total', 'so', 'world', 'look', 'sun'] In [ ] : Part 2. Write a program which generates the list bigrams, collect all attested bigrams in unique_words. Ignore words that are shorter than 2 characters. Make sure that the list bigrams does not contain duplicates. Hint. You can use the code to extract bigrams you wrote above. Then, you need to have that code iterate over each word in the unique words list and add a check for duplicates! In [ ] : Part 3. Based on the variable alphabet, generate all possible bigrams of English. In [ ] : Part 4. Collect all unattested bigrams of English in the list unattested_bigrams . Hint The unattested bigrams are those bigrams that are possible but not attested in the word sample (you collected all attested bigrams before)! Type Markdown and LaTeX: 2 Don't be surprised that some bigrams from unattested_bigrams are actually present in other English words, the text that we are working with is very small! If you are curious, take a larger text, and run your code on it :) In [ ]Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started