forked from kelichiu/GPT3-hate-speech-detection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDRAFT-misspelling.R
64 lines (52 loc) · 2.23 KB
/
DRAFT-misspelling.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
library(tidyverse)
zero_shot_misspelling <- read.csv(here::here("outputs", "data", "zero_shot_misspelling.csv"))
one_shot_misspelling <- read.csv(here::here("outputs", "data", "one_shot_misspelling.csv"))
# Zero-shot
# Summary of results
zero_shot_misspelling <- zero_shot_misspelling %>% separate(prompt, c(NA, "comment", NA), sep = "\"")
zeroshot_summary_race <- zero_shot_misspelling %>%
count(category, comment_id, answer) %>%
count(category, comment_id) %>%
filter(n > 1 & category == "racist")
zeroshot_summary_sex <- zero_shot_misspelling %>%
count(category, comment_id, answer) %>%
count(category, comment_id) %>%
filter(n > 1 & category == "sexist")
# Racist
zero_results_summary <- zero_shot_misspelling %>%
filter(category == "racist" & comment_id %in% zeroshot_summary_race$comment_id) %>%
filter(comment_id != 26) %>% # 'No,' vs. 'No.' for this comment
arrange(comment_id)
results <- tibble()
for (i in unique(zero_results_summary$comment_id)) {
original <- zero_results_summary %>% filter(comment_id == i & status == "unedited")
original_answer <- original["answer"] %>% as.character()
edits <- zero_results_summary %>% filter(comment_id == i & status == "edited" & answer != original_answer)
results <- rbind(results, original, edits)
}
results <- results %>% select(label, status, comment, answer)
# Construct summary table
# Sexist
zero_shot_misspelling %>%
filter(category == "sexist" & comment_id %in% zeroshot_summary_sex$comment_id)%>%
arrange(comment_id) %>%
View()
# One-shot
oneshot_summary_race <- one_shot_misspelling %>%
count(category, comment_id, answer) %>%
count(category, comment_id) %>%
filter(n > 1 & category == "racist")
oneshot_summary_sex <- one_shot_misspelling %>%
count(category, comment_id, answer) %>%
count(category, comment_id) %>%
filter(n > 1 & category == "sexist")
# Racism results
one_shot_misspelling %>%
filter(category == "racist" & comment_id %in% oneshot_summary_race$comment_id)%>%
arrange(comment_id) %>%
View()
# Sexism results
one_shot_misspelling %>%
filter(category == "sexist" & comment_id %in% oneshot_summary_sex$comment_id)%>%
arrange(comment_id) %>%
View()