Commit f1100075 authored by Malith Anjana's avatar Malith Anjana

return json object

parent 65b462f7
...@@ -9,9 +9,9 @@ print('Loading Sentiment Analysis model') ...@@ -9,9 +9,9 @@ print('Loading Sentiment Analysis model')
sa = Sentiment() sa = Sentiment()
app = Flask(__name__) app = Flask(__name__)
bot = ChatBot('Chatterbot', storage_adapter="chatterbot.storage.SQLStorageAdapter") # bot = ChatBot('Chatterbot', storage_adapter="chatterbot.storage.SQLStorageAdapter")
trainer = ChatterBotCorpusTrainer(bot) # trainer = ChatterBotCorpusTrainer(bot)
trainer.train('./chatterbot_training_dataset/ai.yml', './chatterbot_training_dataset/emotion.yml', './chatterbot_training_dataset/conversational.yml') # trainer.train('./chatterbot_training_dataset/ai.yml', './chatterbot_training_dataset/emotion.yml', './chatterbot_training_dataset/conversational.yml')
#trainer.train('./chatterbot_training_dataset/conversational.yml') #trainer.train('./chatterbot_training_dataset/conversational.yml')
#trainer.train('./chatterbot_training_dataset/emotion.yml') #trainer.train('./chatterbot_training_dataset/emotion.yml')
...@@ -22,10 +22,11 @@ def index_test(): ...@@ -22,10 +22,11 @@ def index_test():
new_ma_val = max(pred.items(), key=operator.itemgetter(1))[0] new_ma_val = max(pred.items(), key=operator.itemgetter(1))[0]
avg = json.dumps(str(pred)) #arr = [ {'emotion' : i, 'value' : pred[i]} for i in pred]
avg = json.dumps(pred)
#response from chatbot #response from chatbot
res = str(bot.get_response(js_text['text'])) # res = str(bot.get_response(js_text['text']))
return res return avg
app.run(debug=True, port=8080) app.run(debug=True, port=8080)
\ No newline at end of file
No preview for this file type
...@@ -168,7 +168,8 @@ class Sentiment: ...@@ -168,7 +168,8 @@ class Sentiment:
predictions={} predictions={}
for key , value in zip(encoded_dict.keys(),validation[0]): for key , value in zip(encoded_dict.keys(),validation[0]):
predictions[key]=value st_value = str(value)
predictions[key]=float(st_value)
return predictions return predictions
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment