Question: 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 text_analysis 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).
'difference1': the difference between the first and second set (words in the first text but not in the second).
'difference2': the difference between the second and first set (words in the second text but not in the first).
'symmetric_difference': 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.
 Write a function named text_analysis that accepts two strings as arguments.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!