You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
uni-ba-socialagenda/issuecomp-codingsample-func...

96 lines
3.6 KiB

# A tweet was falsely categorized
if(c_errcode == "1") {
repeat {
c_curissue <- readYN("Which issue is incorrect?: ")
if(c_curissue == "QUIT") {cat("Quitting this item without changes or entries.\n"); break}
c_curissue <- unlist(str_split(c_curissue, ","))
status <- checkAllIssues(c_curissue, c_issueheads)
# Only continue if every given issue really exists (all "status" have to be TRUE)
if(all(status)) {
# Revert str_split
c_curissue <- str_join(c_curissue,collapse = ",")
# <ID>,<all issues>,<faulty issue(s),<all tags>,<tweet text>
c_result <- str_c("\"",c_errid,"\",\"",c_errissue,"\",\"",c_curissue,"\",\"",c_errtags,"\",\"",c_errtext,"\"")
write(c_result, file = "issuecomp-codingsample-error1.csv", append = T)
break
}
}
# A tweet should be categorized with an additional issue
} else if(c_errcode == "2") {
repeat {
c_curissue <- readYN("Which issue is missing?: ")
if(c_curissue == "QUIT") {cat("Quitting this item without changes or entries.\n"); break}
c_curissue <- unlist(str_split(c_curissue, ","))
status <- checkAllIssues(c_curissue, c_issueheads)
# Only continue if every given issue really exists (all "status" have to be TRUE)
if(all(status)) {
# Revert str_split
c_curissue <- str_join(c_curissue,collapse = ",")
# <ID>,<all issues>,<faulty issue(s),<all tags>,<tweet text>
c_result <- str_c("\"",c_errid,"\",\"",c_errissue,"\",\"",c_curissue,"\",\"",c_errtags,"\",\"",c_errtext,"\"")
write(c_result, file = "issuecomp-codingsample-error2.csv", append = T)
break
}
}
# There is an issue missing AND a issue was wrong
} else if(c_errcode == "3") {
# #cat("Which issue is incorrect and which one is missing?\n")
# repeat {
# c_tag <- readYN("Which issue is incorrect?: ")
# c_tag <- unlist(str_split(c_tag, ","))
# for(i in 1:length(c_tag)) {
# if(checkIssue(c_tag[i], c_issueheads)) {} else {cat("Issue",c_tag[i],"does not exist. Please try again.\n")}
# }
repeat {
c_curissue <- readYN("Which issue is incorrect?: ")
if(c_curissue == "QUIT") {cat("Quitting this item without changes or entries.\n"); break}
c_curissue <- unlist(str_split(c_curissue, ","))
status <- checkAllIssues(c_curissue, c_issueheads)
# Only continue if every given issue really exists (all "status" have to be TRUE)
if(all(status)) {
# Revert str_split
c_curissue <- str_join(c_curissue,collapse = ",")
# <ID>,<all issues>,<faulty issue(s),<all tags>,<tweet text>
c_result <- str_c("\"",c_errid,"\",\"",c_errissue,"\",\"",c_curissue,"\",\"",c_errtags,"\",\"",c_errtext,"\"")
write(c_result, file = "issuecomp-codingsample-error1.csv", append = T)
break
}
}
repeat {
c_curissue <- readYN("Which issue is missing?: ")
if(c_curissue == "QUIT") {cat("Quitting this item without changes or entries.\n"); break}
c_curissue <- unlist(str_split(c_curissue, ","))
status <- checkAllIssues(c_curissue, c_issueheads)
# Only continue if every given issue really exists (all "status" have to be TRUE)
if(all(status)) {
# Revert str_split
c_curissue <- str_join(c_curissue,collapse = ",")
# <ID>,<all issues>,<faulty issue(s),<all tags>,<tweet text>
c_result <- str_c("\"",c_errid,"\",\"",c_errissue,"\",\"",c_curissue,"\",\"",c_errtags,"\",\"",c_errtext,"\"")
write(c_result, file = "issuecomp-codingsample-error2.csv", append = T)
break
}
}
# If this triggers the hell freezes...
} else {
cat("Neither 1, 2 or 3 as error code...")
}