You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. The input file is a text file containing one tweet per line.
7
+
2. The set of racial slurs is provided in a text file, with one slur per line.
8
+
3. We consider a tweet to be profane if it contains at least one racial slur.
9
+
4. We measure the degree of profanity as the percentage of racial slurs in the tweet.
10
+
11
+
Explanation:
12
+
13
+
We first read in the file of racial slurs and store them in a vector called slurs. We then read in the file of tweets and store them in a vector called tweets.
14
+
We then loop through each tweet in the tweets vector and perform the following steps:
15
+
1. We split the tweet into individual words using the strsplit function.
16
+
2. We count the number of racial slurs in the tweet by checking which words in the tweet are in the slurs vector and summing up the results.
17
+
3. We calculate the degree of profanity by dividing the number of racial slurs by the total number of words in the tweet and multiplying by 100 to get a percentage.
18
+
4. We print out the tweet and the degree of profanity using the cat function, with appropriate formatting.
0 commit comments