-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFirstCheck_UI.py
More file actions
175 lines (147 loc) · 7.02 KB
/
Copy pathFirstCheck_UI.py
File metadata and controls
175 lines (147 loc) · 7.02 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
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
165
166
167
168
169
170
171
172
173
174
175
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'FirstCheck.ui'
#
# Created by: PyQt5 UI code generator 5.13.1
#
import sys
from sentimentanalyzer import classify
from first_check import search_tweets
from PyQt5 import QtCore, QtGui, QtWidgets
# Creating the GUI
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(542, 370)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
self.gridLayout.setObjectName("gridLayout")
self.disasterLabel = QtWidgets.QLabel(self.centralwidget)
self.disasterLabel.setObjectName("disasterLabel")
self.gridLayout.addWidget(self.disasterLabel, 0, 0, 1, 1)
self.locationLabel = QtWidgets.QLabel(self.centralwidget)
self.locationLabel.setObjectName("locationLabel")
self.gridLayout.addWidget(self.locationLabel, 2, 0, 1, 1)
self.runButton = QtWidgets.QPushButton(self.centralwidget)
self.runButton.setObjectName("runButton")
self.gridLayout.addWidget(self.runButton, 4, 0, 1, 1)
self.locationEntry = QtWidgets.QLineEdit(self.centralwidget)
self.locationEntry.setObjectName("locationEntry")
self.gridLayout.addWidget(self.locationEntry, 3, 0, 1, 1)
self.checkBoxArea = QtWidgets.QScrollArea(self.centralwidget)
self.checkBoxArea.setWidgetResizable(True)
self.checkBoxArea.setObjectName("checkBoxArea")
self.scrollAreaWidgetContents = QtWidgets.QWidget()
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 522, 216))
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
self.gridLayout_2 = QtWidgets.QGridLayout(self.scrollAreaWidgetContents)
self.gridLayout_2.setObjectName("gridLayout_2")
self.earthquakeBox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.earthquakeBox.setObjectName("earthquakeBox")
self.gridLayout_2.addWidget(self.earthquakeBox, 0, 0, 1, 1)
self.floodBox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.floodBox.setObjectName("floodBox")
self.gridLayout_2.addWidget(self.floodBox, 1, 0, 1, 1)
self.hurricaneBox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.hurricaneBox.setObjectName("hurricaneBox")
self.gridLayout_2.addWidget(self.hurricaneBox, 2, 0, 1, 1)
self.checkBox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.checkBox.setObjectName("checkBox")
self.gridLayout_2.addWidget(self.checkBox, 3, 0, 1, 1)
self.checkBoxArea.setWidget(self.scrollAreaWidgetContents)
self.gridLayout.addWidget(self.checkBoxArea, 1, 0, 1, 1)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 542, 21))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
self.runButton.clicked.connect(self.run_tweets)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "First Check"))
self.disasterLabel.setText(_translate("MainWindow", "Choose a Disaster (Pick one)"))
self.locationLabel.setText(_translate("MainWindow", "Enter a Location"))
self.runButton.setText(_translate("MainWindow", "Check Tweets"))
self.earthquakeBox.setText(_translate("MainWindow", "Earthquake"))
self.floodBox.setText(_translate("MainWindow", "Flood"))
self.hurricaneBox.setText(_translate("MainWindow", "Hurricane"))
self.checkBox.setText(_translate("MainWindow", "Tornado"))
#calling the API functions.
def run_tweets(self):
if (self.earthquakeBox.isChecked()):
disaster="earthquake"
number=200
textBoxVal=self.locationEntry.text()
location=textBoxVal
search_tweets(disaster, number)
openfile = open("all_dis.txt","r")
readfile = openfile.read()
tweetstrings = readfile.split('[BEGIN]')
tweets = [x.strip() for x in tweetstrings if len(x) != 0]
# tweets = [x.replace('\n+', ' ') for x in tweets]
for tweet in tweets:
classifiedtweet = classify(tweet)
if any(location in classifiedtweet):
writingtweet = open("disastertweets.txt","x+")
writingtweet.write(classifiedtweet)
elif (self.hurricaneBox.isChecked()):
disaster="hurricane"
number=200
textBoxVal=self.locationEntry.text()
location=textBoxVal
search_tweets(disaster, number)
openfile = open("all_dis.txt","r")
readfile = openfile.read()
tweetstrings = readfile.split('[BEGIN]')
tweets = [x.strip() for x in tweetstrings if len(x) != 0]
# tweets = [x.replace('\n+', ' ') for x in tweets]
for tweet in tweets:
classifiedtweet = classify(tweet)
if any(location in classifiedtweet):
writingtweet = open("disastertweets.txt","x+")
writingtweet.write(classifiedtweet)
elif (self.floodBox.isChecked()):
disaster="flood"
number=200
textBoxVal=self.locationEntry.text()
location=textBoxVal
search_tweets(disaster, number)
openfile = open("all_dis.txt","r")
readfile = openfile.read()
tweetstrings = readfile.split('[BEGIN]')
tweets = [x.strip() for x in tweetstrings if len(x) != 0]
# tweets = [x.replace('\n+', ' ') for x in tweets]
for tweet in tweets:
classifiedtweet = classify(tweet)
if any(location in classifiedtweet):
writingtweet = open("disastertweets.txt","x+")
writingtweet.write(classifiedtweet)
elif (self.checkBox.isChecked()):
disaster="tornado"
number=200
textBoxVal=self.locationEntry.text()
location=textBoxVal
search_tweets(disaster, number)
openfile = open("all_dis.txt","r")
readfile = openfile.read()
tweetstrings = readfile.split('[BEGIN]')
tweets = [x.strip() for x in tweetstrings if len(x) != 0]
# tweets = [x.replace('\n+', ' ') for x in tweets]
for tweet in tweets:
classifiedtweet = classify(tweet)
if any(location in classifiedtweet):
writingtweet = open("disastertweets.txt","x+")
writingtweet.write(classifiedtweet)
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_())