-
Notifications
You must be signed in to change notification settings - Fork 0
/
memeHash.py
39 lines (31 loc) · 965 Bytes
/
memeHash.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from random import randrange
import cv2
import numpy as np
def openFile(file):
lineList = []
for line in open(file):
items = line.split(',')
while len(items) < 2:
items.append('')
lineList.append((items[0], items[1]))
return lineList
def getRandomMeme(lineList):
return (lineList[randrange(len(lineList))])
angerMemes = openFile('angry.txt')
joyMemes = openFile('joy.txt')
sorrowMemes = openFile('sorrow.txt')
surpriseMemes = openFile('surprise.txt')
def getEmotionListName(dictionary):
l = [dictionary['joy:'], dictionary['sorrow:'], dictionary['anger:'], dictionary['surprise:']]
temp = l.index(max(l))
if temp == 0:
return joyMemes
elif temp == 1:
return sorrowMemes
elif temp == 2:
return angerMemes
else:
return surpriseMemes
def memeCreator(dictionary):
emotionListName = getEmotionListName(dictionary)
return getRandomMeme(emotionListName)