Spaces:
Build error
Build error
yangxinsci1993
commited on
Commit
•
c160098
1
Parent(s):
91081a2
Edit error message
Browse files
app.py
CHANGED
@@ -14,14 +14,16 @@ def reframe(text, strategy):
|
|
14 |
text_with_strategy = text + "Strategy: ['" + strategy + "']"
|
15 |
#Input Control
|
16 |
#The input text cannot be too short to ensure it has substantial content to be reframed. It also cannot be too long to ensure the text has a focused idea.
|
17 |
-
if len(text) < 15
|
18 |
-
return "Please try again by inputing text with moderate length."
|
|
|
|
|
19 |
if TextBlob(text).sentiment.polarity > 0.2:
|
20 |
-
return "Please try again by inputing text that is negative."
|
21 |
from hatesonar import Sonar
|
22 |
sonar = Sonar()
|
23 |
if sonar.ping(text)['classes'][1]['confidence'] > 0.8:
|
24 |
-
return "Please try again by not inputing offensive language."
|
25 |
#if TextBlob(text).sentiment.polarity > 0:
|
26 |
# return "Please try again by inputing text that is negative."
|
27 |
return reframer(text_with_strategy)[0]['summary_text']
|
|
|
14 |
text_with_strategy = text + "Strategy: ['" + strategy + "']"
|
15 |
#Input Control
|
16 |
#The input text cannot be too short to ensure it has substantial content to be reframed. It also cannot be too long to ensure the text has a focused idea.
|
17 |
+
if len(text) < 15:
|
18 |
+
return "[Error]: Input is too short. Please try again by inputing text with moderate length."
|
19 |
+
if len(text) > 150:
|
20 |
+
return "[Error]: Input is too long. Please try again by inputing text with moderate length."
|
21 |
if TextBlob(text).sentiment.polarity > 0.2:
|
22 |
+
return "[Error]: Input is too positive. Please try again by inputing text that is negative."
|
23 |
from hatesonar import Sonar
|
24 |
sonar = Sonar()
|
25 |
if sonar.ping(text)['classes'][1]['confidence'] > 0.8:
|
26 |
+
return "[Error]: Input is offensive. Please try again by not inputing offensive language."
|
27 |
#if TextBlob(text).sentiment.polarity > 0:
|
28 |
# return "Please try again by inputing text that is negative."
|
29 |
return reframer(text_with_strategy)[0]['summary_text']
|