-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gui.py
164 lines (151 loc) · 6.95 KB
/
gui.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
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'untitled.ui'
#
# Created by: PyQt5 UI code generator 5.15.1
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
import movie_recommender
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(973, 646)
MainWindow.setWindowOpacity(1.0)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(180, 240, 231, 31))
self.pushButton.setObjectName("pushButton")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(440, 150, 511, 111))
font = QtGui.QFont()
font.setPointSize(12)
self.label.setFont(font)
self.label.setText("")
self.label.setObjectName("label")
self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_2.setGeometry(QtCore.QRect(180, 430, 231, 31))
self.pushButton_2.setObjectName("pushButton_2")
self.label_2 = QtWidgets.QLabel(self.centralwidget)
self.label_2.setGeometry(QtCore.QRect(10, 120, 131, 21))
self.label_2.setObjectName("label_2")
self.textEdit = QtWidgets.QTextEdit(self.centralwidget)
self.textEdit.setGeometry(QtCore.QRect(180, 110, 241, 101))
self.textEdit.setObjectName("textEdit")
self.label_3 = QtWidgets.QLabel(self.centralwidget)
self.label_3.setGeometry(QtCore.QRect(10, 380, 131, 21))
self.label_3.setObjectName("label_3")
self.lineEdit = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit.setGeometry(QtCore.QRect(180, 380, 231, 20))
self.lineEdit.setObjectName("lineEdit")
self.label_4 = QtWidgets.QLabel(self.centralwidget)
self.label_4.setGeometry(QtCore.QRect(270, 10, 451, 41))
font = QtGui.QFont()
font.setFamily("Goudy Old Style")
font.setPointSize(20)
font.setBold(True)
font.setItalic(False)
font.setUnderline(False)
font.setWeight(75)
self.label_4.setFont(font)
self.label_4.setObjectName("label_4")
self.label_5 = QtWidgets.QLabel(self.centralwidget)
self.label_5.setGeometry(QtCore.QRect(600, 60, 231, 31))
font = QtGui.QFont()
font.setPointSize(14)
self.label_5.setFont(font)
self.label_5.setObjectName("label_5")
self.label_6 = QtWidgets.QLabel(self.centralwidget)
self.label_6.setGeometry(QtCore.QRect(440, 320, 511, 281))
font = QtGui.QFont()
font.setPointSize(12)
self.label_6.setFont(font)
self.label_6.setText("")
self.label_6.setObjectName("label_6")
self.label_7 = QtWidgets.QLabel(self.centralwidget)
self.label_7.setGeometry(QtCore.QRect(630, 280, 231, 31))
font = QtGui.QFont()
font.setPointSize(14)
self.label_7.setFont(font)
self.label_7.setObjectName("label_7")
self.label_8 = QtWidgets.QLabel(self.centralwidget)
self.label_8.setGeometry(QtCore.QRect(770, 110, 231, 31))
font = QtGui.QFont()
font.setPointSize(12)
self.label_8.setFont(font)
self.label_8.setObjectName("label_8")
self.label_9 = QtWidgets.QLabel(self.centralwidget)
self.label_9.setGeometry(QtCore.QRect(480, 110, 231, 31))
font = QtGui.QFont()
font.setPointSize(12)
self.label_9.setFont(font)
self.label_9.setObjectName("label_9")
self.label_10 = QtWidgets.QLabel(self.centralwidget)
self.label_10.setGeometry(QtCore.QRect(770, 140, 171, 111))
font = QtGui.QFont()
font.setPointSize(12)
self.label_10.setFont(font)
self.label_10.setText("")
self.label_10.setObjectName("label_10")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 973, 20))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.textEdit.setPlaceholderText("Enter one movie per line.\nThe Terminator\nAvengers")
self.lineEdit.setPlaceholderText("Die Hard")
self.pushButton.clicked.connect(lambda: self.getmoviereccomendation())
self.pushButton_2.clicked.connect(lambda: self.getmovieinfo())
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "Movie Recommender System"))
self.pushButton.setText(_translate("MainWindow", "Get Reccomendations"))
self.label.setText(_translate("MainWindow", " "))
self.pushButton_2.setText(_translate("MainWindow", "Get Movie Info."))
self.label_2.setText(_translate("MainWindow", "Name of the Movies:"))
self.label_3.setText(_translate("MainWindow", "Name of the Movie:"))
self.label_4.setText(_translate("MainWindow", " Movie Recommender System"))
self.label_5.setText(_translate("MainWindow", "Recommended Movies"))
self.label_7.setText(_translate("MainWindow", "Movie Details"))
self.label_8.setText(_translate("MainWindow", "Similarity"))
self.label_9.setText(_translate("MainWindow", "Movie"))
self.label_2.adjustSize()
self.label_3.adjustSize()
self.label_4.adjustSize()
self.label_5.adjustSize()
self.label_7.adjustSize()
self.label_8.adjustSize()
self.label_9.adjustSize()
def getmoviereccomendation(self):
movie_name=self.textEdit.toPlainText()
movie_name=movie_name.split("\n")
final=movie_recommender.get_recommendations(movie_name)
final.reverse()
recommendations=''
similarity=''
for x in final:
recommendations=recommendations+str(x[0])+"\n"
similarity=similarity+str(x[1])+"%"+"\n"
self.label.setText(recommendations)
self.label.adjustSize()
self.label_10.setText(similarity)
self.label_10.adjustSize()
def getmovieinfo(self):
movie_name=self.lineEdit.text()
final=movie_recommender.get_info(movie_name)
self.label_6.setWordWrap(True)
self.label_6.setText(final)
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())