forked from lordboba/BooksxMovies
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mov_preproc.py
34 lines (32 loc) · 908 Bytes
/
mov_preproc.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
#This code preprocesses our existing database
import json
import encode
with open('movie_info.json', 'r') as f:
movies = json.load(f)
with open('movie_grid.json', 'r') as f:
gridz = json.load(f)
#x = encode.embedd("BEYOND ORDER")
# print(x)
#with open("book_grid.json",'a') as f:
sum =0
for title in movies:
if title in gridz:
continue
info = movies[title]
desc = info["Plot"]
if desc == "":
desc = title
tensor = encode.embedd(desc)
rating = 0.0
# print(type(info["Rating"]))
try:
rating = float(info["Rating"])/10
except ValueError:
rating = 0.78
tensor.append(rating)
gridz[title] = [tensor,info["Title"],info["Plot"],info["Poster"],info["Rated"],info["Actors"]]
sum = sum + 1
if sum %10 == 0:
print(f"sus {len(gridz)}")
with open('movie_grid.json', 'w') as f:
json.dump(gridz,f)