Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a function named text _ analysis that accepts two strings as arguments. The function should perform multiple operations to analyze the words in the
Write a function named textanalysis that accepts two strings as arguments. The function should perform multiple operations to analyze the words in the texts. Here's what it should do:
Convert each string into a set of lowercase words. Assume words are separated by spaces, and punctuations are not considered part of a word.
Calculate and return a dictionary containing the following keys:
'union': the union of the two sets all unique words in both texts
'intersection': the intersection of the two sets words common to both texts
'difference: the difference between the first and second set words in the first text but not in the second
'difference: the difference between the second and first set words in the second text but not in the first
'symmetricdifference': the symmetric difference between the two sets words in either of the texts but not in both
Each set should be a key in the returned dictionary, with the corresponding set of words as its value.
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