def __init__(self): super().__init__() Emotions.loadEmotions() Bots.loadBots() self.__current__bot__ = Bots.getGeneral() self.__current__bot__index__ = 0 Entries.loadEntries(self.__current__bot__)
def test_find_2(self): term = "giận" emotion = Emotions.find(term) self.assertEqual(emotion.name, "giận dữ") term = "cáu" emotion = Emotions.find(term) self.assertEqual(emotion.name, "giận dữ")
def test_level_2(self): term = "tin tưởng" response(term) emotion = Emotions.find(term) levels = ["tán thành", "ngưỡng mộ"] self.assertEqual(emotion.levels, levels) self.assertIsNotNone(emotion.levels)
def __init__(self, text="", type=AnswerTypes.NONE, emotions=None): self.type = type self.text = text if (emotions is not None): self.emotions = emotions else: self.emotions = [1 for x in range(Emotions.getLength())] self.data = self.to_dict()
def response(term): term = term.strip().lower() item = Emotions.find(term) if item: item.display() print() else: print(f"Không tìm thấy \"{term}\"")
from flask import Flask, render_template, Response, jsonify, request from camera import VideoCamera from camera import predict from data import Emotions import cv2 import numpy as np from keras.models import model_from_json from keras.preprocessing import image app = Flask(__name__) video_camera = VideoCamera() global_frame = None Emotions = Emotions() # ===================FOR DEVELOPMENT ONLY================= app.debug = True # ========================================= @app.route('/whatemotion') def emotion(): return render_template('emotions.html', emotion=predict()) # VIDEO RECORDING @app.route('/record_status', methods=['POST']) def record_status():
def test_attr_1(self): term = "giận" emotion = Emotions.find(term) synonym_terms = {'cáu', 'hậm hực', 'tức giận', 'điên tiết', 'giận'} self.assertEqual(emotion.synonym, synonym_terms)
def test_find_1(self): term = "buồn" emotion = Emotions.find(term) self.assertEqual(emotion.name, term)
def test_level_1(self): term = "hậm hực" emotion = Emotions.find(term) print(emotion) levels = ['tức giận', 'điên tiết', 'hậm hực'] self.assertEqual(emotion.levels, levels)