forked from raysandeep/FMIYC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
imdbFuncs.py
33 lines (28 loc) · 855 Bytes
/
imdbFuncs.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
import json
from collections import Counter
'''
celebs: list of strings (celeb names)
return: list of 5 strings (top guesses)
'''
def getGuessesFromCelebs(celebs):
json_file = open('actorsToMovies.json')
json_str = json_file.read()
actorsToMovies = json.loads(json_str)
movies = Counter()
print("!", celebs)
for celeb in celebs:
if celeb[0] in actorsToMovies:
for movie in actorsToMovies[celeb[0]]:
movies[movie]+=celeb[1]
print(movies.most_common(5))
return movies.most_common(5)
def bruteForce(text):
json_file = open('movies.json')
json_str = json_file.read()
movies = json.loads(json_str)
movieCounter = Counter()
for movie in movies:
count = text.count(movie)
if count > 0:
movieCounter[movie] += count
return movieCounter