Commit f1100075 authored by Malith Anjana's avatar Malith Anjana

return json object

parent 65b462f7
......@@ -9,9 +9,9 @@ print('Loading Sentiment Analysis model')
sa = Sentiment()
app = Flask(__name__)
bot = ChatBot('Chatterbot', storage_adapter="chatterbot.storage.SQLStorageAdapter")
trainer = ChatterBotCorpusTrainer(bot)
trainer.train('./chatterbot_training_dataset/ai.yml', './chatterbot_training_dataset/emotion.yml', './chatterbot_training_dataset/conversational.yml')
# bot = ChatBot('Chatterbot', storage_adapter="chatterbot.storage.SQLStorageAdapter")
# 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/conversational.yml')
#trainer.train('./chatterbot_training_dataset/emotion.yml')
......@@ -22,10 +22,11 @@ def index_test():
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
res = str(bot.get_response(js_text['text']))
return res
# res = str(bot.get_response(js_text['text']))
return avg
app.run(debug=True, port=8080)
\ No newline at end of file
No preview for this file type
......@@ -168,7 +168,8 @@ class Sentiment:
predictions={}
for key , value in zip(encoded_dict.keys(),validation[0]):
predictions[key]=value
st_value = str(value)
predictions[key]=float(st_value)
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