autocorrect

This commit is contained in:
QuoteFox
2021-02-07 02:29:18 +00:00
parent 5480cd9700
commit 9e2480fc95
2 changed files with 41 additions and 0 deletions
+40
View File
@@ -779,6 +779,46 @@ GLOBAL_LIST_INIT(binary, list("0","1"))
shuffle_inplace(rearranged)
return "[prefix][jointext(rearranged, " ")]"
/proc/autocorrect(var/input as text) // syntax is "stringtoreplace"="stringtoreplacewith"
return input = replace_characters(input, list(
" i "=" I ",
"i'm"="I'm",
"s's"="s'",
"isnt"="isn't",
"dont"="don't",
"shouldnt"="shouldn't",
" ive "=" I've ",
"whos"="who's",
"whove"="who've",
"whod"="whod",
"whats"="whats",
"whatd"="whatd",
"thats"="thats",
"thatll"="thatll",
"thatd"="thatd",
" nows "=" nows ",
"isnt"="isnt",
"arent"="arent",
"wasnt"="wasnt",
"werent"="werent",
"havent"="havent",
"hasnt"="hasnt",
"hadnt"="hadnt",
"doesnt"="doesnt",
"didnt"="didnt",
"couldnt"="couldnt",
"wouldnt"="wouldnt",
"mustnt"="mustnt",
"shouldnt"="shouldnt"
))
/*
* Text modification
*/
/proc/replace_characters(var/t,var/list/repl_chars)
for(var/char in repl_chars)
t = replacetext(t, char, repl_chars[char])
return t
#define is_alpha(X) ((text2ascii(X) <= 122) && (text2ascii(X) >= 97))
#define is_digit(X) ((length(X) == 1) && (length(text2num(X)) == 1))
+1
View File
@@ -174,6 +174,7 @@ GLOBAL_LIST_INIT(department_radio_keys, list(
src.log_talk(message, LOG_SAY, forced_by=forced)
message = treat_message(message) // unfortunately we still need this
message = autocorrect(message)
var/sigreturn = SEND_SIGNAL(src, COMSIG_MOB_SAY, args)
if (sigreturn & COMPONENT_UPPERCASE_SPEECH)
message = uppertext(message)