Pruned censor list to get rid of words that shouldn't be censored. Also added ability to turn censor on and off (#94)

This commit is contained in:
Nick Walton
2019-12-10 12:06:30 -07:00
committed by GitHub
parent 1f20e9f4a4
commit 81e8979e37
5 changed files with 115 additions and 9 deletions
+4 -2
View File
@@ -13,11 +13,12 @@ tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
class GPT2Generator:
def __init__(self, generate_num=60, temperature=0.4, top_k=40, top_p=0.9):
def __init__(self, generate_num=60, temperature=0.4, top_k=40, top_p=0.9, censor=True):
self.generate_num = generate_num
self.temp = temperature
self.top_k = top_k
self.top_p = top_p
self.censor = censor
self.model_name = "model_v5"
self.model_dir = "generator/gpt2/models"
@@ -79,7 +80,8 @@ class GPT2Generator:
result = result.replace("*", "")
result = result.replace("\n\n", "\n")
# result = first_to_second_person(result)
result = remove_profanity(result)
if self.censor:
result = remove_profanity(result)
if not first_letter_capitalized:
result = result[0].lower() + result[1:]
+7
View File
@@ -88,6 +88,7 @@ def instructions():
text += '\n "load" Asks for a save ID and loads the game if the ID is valid'
text += '\n "print" Prints a transcript of your adventure (without extra newline formatting)'
text += '\n "help" Prints these instructions again'
text += '\n "censor off/on" to turn censoring off or on.'
return text
@@ -159,6 +160,12 @@ def play_aidungeon_2():
elif action == "help":
console_print(instructions())
elif action == "censor off":
generator.censor = False
elif action == "censor on":
generator.censor = True
elif action == "save":
if upload_story:
id = story_manager.story.save_to_storage()
+100
View File
@@ -0,0 +1,100 @@
BlowJob
Clit
Cock
CockSucker
Goddamned
MothaFucker
MothaFuker
MothaFukkah
MothaFukker
MotherFucker
MotherFukah
MotherFuker
MotherFukkah
MotherFukker
MuthaFucker
MuthaFukah
MuthaFuker
MuthaFukkah
MuthaFukker
Shitty
Shity
anus
ass
asshole
assholes
assrammer
asswipe
b1tch
bastard
bastards
bitch
bitches
blowjob
boobs
bullshit
butthole
buttwipe
clit
clits
cock
cockhead
cocks
cocksucker
cum
cunt
cunts
damn
dick
dildo
dildos
ejackulate
ejakulate
fatass
foreskin
fuck
fucka
fucker
fuckin
fucking
fucks
fuk
hell
hells
jackoff
jerkoff
jizz
masturbate
motherfucker
nigga
niggas
nigger
nigur
niiger
niigr
nutsack
orgasm
penis
pussy
rectum
scrotum
semen
sexy
shit
shits
testical
testicle
tit
tits
titt
vag1na
vagiina
vagina
vaj1na
vajina
whore
xrated
xxx
rape
shitting
raped
-3
View File
@@ -1,3 +0,0 @@
rape
shitting
raped
+4 -4
View File
@@ -8,10 +8,10 @@ from profanityfilter import ProfanityFilter
YAML_FILE = "story/story_data.yaml"
with open("story/extra_censored_words.txt", "r") as f:
more_words = [l.replace("\n", "") for l in f.readlines()]
with open("story/censored_words.txt", "r") as f:
censored_words = [l.replace("\n", "") for l in f.readlines()]
pf = ProfanityFilter(extra_censor_list=more_words)
pf = ProfanityFilter(custom_censor_list=censored_words)
def console_print(text, width=75):
@@ -285,4 +285,4 @@ def second_to_first_person(text):
for variation in variations:
text = replace_outside_quotes(text, variation[0], variation[1])
return capitalize_first_letters(text[1:])
return capitalize_first_letters(text[1:])