示例#1
0
def recognitions():
    if request.method == 'POST':
        data = request.get_json()
        x = data["base64Image"].split(',')
        base64_decoded = base64.b64decode(x[1])
        image = Image.open(io.BytesIO(base64_decoded))
        image_np = np.array(image)
        t = time.time()
        result = get_emotion(image_np)
        print(result)
        print(time.time() - t)
        return json.dumps(result)
示例#2
0
文件: app.py 项目: sanhalim/ketchup
    def post(self, id):
        args = self.reqparse.parse_args()
        text = args["text"]
        
        # getting sentiment analysis from google nlp api
        annotations = get_sentiment(text)
        sentiment = annotations.document_sentiment.score

        # getting emotion from deepaffects text api
        emotion = list(json.loads(get_emotion(text).text)["response"].keys())[0]
        ketchup = CheckIn(id, text, sentiment, emotion)
        self.add_checkin_to_db(ketchup)
        most_common, average, slope, r2 = self.get_data(id)
        return jsonify({"emotion": emotion, "sentiment": sentiment, "most_freq_emotion": most_common, "average_sentiment": average, "slope": slope, "r2": r2})
示例#3
0
文件: app.py 项目: thoratvinod/MOM
def predict():
    label = get_emotion()
    return redirect('/musicplayer?mood=' + label)
示例#4
0
import pandas as pd
import re #清楚数字标点的标准库
from textblob import TextBlob
import  emotion
from nltk.corpus import stopwords  # 下载之后 载入字典
from nltk.stem.porter import PorterStemmer  # stem:词根 PorterStemmer: 词根函数库


positive, negative = emotion.get_emotion()
positive = tuple(positive)
negative = tuple(negative)

table = "microwave"

# dataset = pd.read_csv('data/hair_dryer.tsv', delimiter = '\t', quoting = 3, encoding='utf-8')
# dataset = pd.read_csv('data/pacifier.tsv', delimiter = '\t', quoting = 3, encoding='utf-8')

dataset = pd.read_csv('data/microwave.tsv', delimiter = '\t', quoting = 3, encoding='utf-8')

def get_scores():

    corpus = []  # 空list
    lens = len(dataset)

    listc = []
    mp = dict()
    k = 0
    sum = 0
    scorce = []
    sum_count = 0
    for i in range(0, lens):
示例#5
0
def get_emotion_of_text():
    if request.method == 'POST':
        text = request.json.get('text')
        return get_emotion(text)