-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbotfunctions.py
More file actions
80 lines (38 loc) · 1.29 KB
/
botfunctions.py
File metadata and controls
80 lines (38 loc) · 1.29 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import difflib
def bot():
# x = ['#' , '*' , '$' , '!']
x = message_text.split(' ')
for item in x :
if '#' in item :
SongName = x.split('#')[1]
matches = matching_algo(SongName , SongNameData)
elif '*' in item :
SongCast = x.split('*')[1]
matches = matching_algo(SongCast , CastData)
elif '$' in item :
Actors = x.split('$')[1]
matches = matching_algo(Actors , ActorsData)
elif '!' in item :
Mood = Mood.split('!')[1]
matches = matching_algo(Mood , MoodData)
def matching_algo(input_string , data) :
for item in data:
a = []
s = difflib.SequenceMatcher(None, item, input_string).ratio()
a.append(s)
for i in range(3):
match = data[a.index(max(a))]
matches = []
matches.append(match)
a.remove(max(a))
return matches
def query():
q = Singer.objects.filter(Name__contains = userInstance.Singer)
w = Year.objects.filter(year__contains = userInstance.year)
e = Category.objects.filter(Name__contains = userInstance.Category)
r = Actor.objects.filter(Name__contains = userInstance.Cast)
t = Lyricist.objects.filter(Name__contains = userInstance.Lyricist)
# y = Song.objects.filter(SongName__contains = )
print a
b = Song.objects.filter(Singer=a , Lyricist = t , Actor = r , Category = e , year = )
print b