Spaces:
Runtime error
Runtime error
Commit
·
cb8913f
1
Parent(s):
05faae5
Update models.py
Browse files
models.py
CHANGED
|
@@ -34,10 +34,17 @@ def modelsummary(data):
|
|
| 34 |
return { 'summary':result}
|
| 35 |
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
#Sentiment model
|
| 38 |
def modelpredict(data):
|
| 39 |
-
|
|
|
|
| 40 |
pred = model_sentiment.predict(pd.Series([data]))
|
| 41 |
-
return {
|
| 42 |
-
|
|
|
|
| 43 |
|
|
|
|
| 34 |
return { 'summary':result}
|
| 35 |
|
| 36 |
|
| 37 |
+
# def modelpredict(data):
|
| 38 |
+
# map = {0:'anger', 1:'sadness', 2:'joy', 3:'surprise', 4:'love', 5:'sympathy', 6:'fear'}
|
| 39 |
+
# text = txt_preprocess(data)
|
| 40 |
+
# pred=model.predict(pd.Series([data]))
|
| 41 |
+
# return {"emotion":map[np.argmax(pred,axis=-1)[0]]}
|
| 42 |
#Sentiment model
|
| 43 |
def modelpredict(data):
|
| 44 |
+
map = {0:'anger', 1:'sadness', 2:'joy', 3:'surprise', 4:'love', 5:'sympathy', 6:'fear'}
|
| 45 |
+
data = Cleaning.txt_preprocess(data)
|
| 46 |
pred = model_sentiment.predict(pd.Series([data]))
|
| 47 |
+
return {"label":map[np.argmax(pred,axis=-1)[0]]}
|
| 48 |
+
# return {'anger': float(pred[0][0]), 'sadness': float(pred[0][1]), 'joy': float(pred[0][2]), 'surprise': float(pred[0][3]),
|
| 49 |
+
# 'love': float(pred[0][4]), 'sympathy': float(pred[0][5]), 'fear': float(pred[0][6])}
|
| 50 |
|