Skip to content

Commit 52b5f18

Browse files
authored
Assumptions & Explaination
1 parent b5640fe commit 52b5f18

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,18 @@
11
# Assignment
22
Affinity Answers
3+
4+
Assumptions:
5+
6+
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

Comments
 (0)