Spaces:
Running
Running
skip toxicity test of harvard sentences
Browse files
app.py
CHANGED
@@ -594,7 +594,11 @@ def synthandreturn(text):
|
|
594 |
raise gr.Error(f'You exceeded the limit of {MAX_SAMPLE_TXT_LENGTH} characters')
|
595 |
if len(text) < MIN_SAMPLE_TXT_LENGTH:
|
596 |
raise gr.Error(f'Please input a text longer than {MIN_SAMPLE_TXT_LENGTH} characters')
|
597 |
-
if (
|
|
|
|
|
|
|
|
|
598 |
print(f'Detected toxic content! "{text}"')
|
599 |
raise gr.Error('Your text failed the toxicity test')
|
600 |
if not text:
|
|
|
594 |
raise gr.Error(f'You exceeded the limit of {MAX_SAMPLE_TXT_LENGTH} characters')
|
595 |
if len(text) < MIN_SAMPLE_TXT_LENGTH:
|
596 |
raise gr.Error(f'Please input a text longer than {MIN_SAMPLE_TXT_LENGTH} characters')
|
597 |
+
if (
|
598 |
+
# test toxicity if not prepared text
|
599 |
+
text not in sents
|
600 |
+
and toxicity.predict(text)['toxicity'] > 0.8
|
601 |
+
):
|
602 |
print(f'Detected toxic content! "{text}"')
|
603 |
raise gr.Error('Your text failed the toxicity test')
|
604 |
if not text:
|