-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUI2.py
More file actions
233 lines (163 loc) · 6.45 KB
/
Copy pathGUI2.py
File metadata and controls
233 lines (163 loc) · 6.45 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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
from tkinter import *
from tkinter import ttk
from tkinter import filedialog
from productionCode import *
from activePassive import *
from deleteUnnecesaryWords import *
from nominalization import *
from smallerSentenceWithBackTracking import *
import re
from regexFixing import *
########################
#
#
# Create window for content and buttons
#
#
########################
# main window
root = Tk()
# A window pane for all content
paneForAllContent = ttk.Panedwindow(root, orient=HORIZONTAL)
# Put the window pane into root
paneForAllContent.pack(fill=BOTH, expand=True)
# A frame for buttons that will go inside paneForAllContent
frameForButtons = ttk.Frame(paneForAllContent, width=100, height=100, relief=SUNKEN)
# A frame for the text to go into paneForAllContent
frameForText = ttk.Frame(paneForAllContent, width=500, height=500)
# Put the frames inside the paneForAllContent
paneForAllContent.add(frameForButtons, weight=1)
paneForAllContent.add(frameForText, weight=4)
##############################
#
#
# Create buttons
#
#
##############################
#############################
# Button for loading text
#############################
# A button that will put text onto screen
loadTextButton = ttk.Button(frameForButtons, text = "Load your text")
# Button functionality
loadTextButton.config(command = lambda : getFilePathReadText())
# Puts button onto frameForButtons
loadTextButton.pack(anchor=W, padx=10, pady = 10)
####################################################
# Button for changing passive voice to active voice
####################################################
# Button for changing passive voice to active voice
changePassiveToActive = ttk.Button(frameForButtons, text="Change passive voice to active voice")
# Button functionality
changePassiveToActive.config(command= lambda : changePassiveSentencesToActive())
# Puts button onto frameForButtons
changePassiveToActive.pack(anchor=W, padx=10, pady=10)
###############################
# Button for nominalizations
###############################
# Button for nominalizations
checkForNominalizations = ttk.Button(frameForButtons, text="Check for nominalizations")
# Button functionality
checkForNominalizations.config(command= lambda : checkNominalizations())
# Puts button onto frameForButtons
checkForNominalizations.pack(anchor=W, padx=10, pady=10)
#########################################
# Button for removing unnecessary words
#########################################
# Button to remove unnecessary words
removeUncessaryWords = ttk.Button(frameForButtons, text = "Remove unnecessary words")
# Button functionality
removeUncessaryWords.config(command= lambda : removeUnnecessaryWordsFromText())
# Puts button onto frameForButtons
removeUncessaryWords.pack(anchor=W, padx=10, pady=10)
###################################
# Button for shortening sentences
###################################
# Button to remove unnecessary words
shortenSentences = ttk.Button(frameForButtons, text = "Shorten sentences")
# Button functionality
shortenSentences.config(command= lambda : shortenSentences() )
# Puts button onto frameForButtons
shortenSentences.pack(anchor=W, padx=10, pady=10)
################################
# Button for testing functions
################################
# Create button
# testButton = ttk.Button(frameForButtons, text="TEST BUTTON")
# Functionality
# testButton.config(command= lambda : insertEditedText())
# Place button onto frameForButtons
# testButton.pack(anchor=W, padx=10, pady=10)
###################################
#
# Functions for buttons
#
###################################
####################################################
####### BUTTON FUNCTION TO LOAD TEXT ONTO THE SCREEN ##############
####################################################
# someText is a text frame object. Text
someText = Text(frameForText)
def getFilePathReadText():
filename = filedialog.askopenfile('r')
someText.insert(END, filename.read())
someText.config(wrap='word')
someText.pack()
return filename
####################################################
####### BUTTON FUNCTION TO GET TEXT FROM TEXT BOX ##############
####################################################
# Used for all functions because all functions need to get the text from
# the text box.
def getContentFromTextBox():
content = someText.get("1.0", END) # gets content in text frame
return content
###############################################
####### BUTTON FUNCTION FOR ACTIVE TO PASSIVE ##############
###############################################
def changePassiveSentencesToActive():
onScreenText = getContentFromTextBox()
changedText = outputText(onScreenText)
inputText = fixErrors(changedText)
someText.delete("1.0", END)
someText.insert("1.0", inputText)
########################################################
####### BUTTON FUNCTION FOR REMOVING UNNECESSARY WORDS ##############
########################################################
def removeUnnecessaryWordsFromText():
onScreenText = getContentFromTextBox()
changedText = removeUnnessaryWords(onScreenText)
inputText = fixErrors(changedText)
someText.delete("1.0", END)
someText.insert("1.0", inputText)
########################################################
####### BUTTON FUNCTION FOR CHECKING FOR NOMINALIZATIONS ##############
########################################################
def checkNominalizations():
onScreenText = getContentFromTextBox()
changedText = nominalizationIdentification(onScreenText)
inputText = fixErrors(changedText)
someText.delete("1.0", END)
someText.insert("1.0", inputText)
###############################################
####### BUTTON FUNCTION FOR SHORTENING SENTENCES ##############
###############################################
def shortenSentences():
onScreenText = getContentFromTextBox()
changedText = makeSentenceSmaller(onScreenText)
inputText = fixErrors(changedText)
someText.delete("1.0", END)
someText.insert("1.0", inputText)
################################
# Testing button functionality #
################################
def printFileContnet():
stuffInTextFrame = someText.get("1.0", END)
# print(stuffInTextFrame)
def sentenceAnalysis():
stuffInTextFrame = someText.get("1.0", END)
analysis = getSentenceData(stuffInTextFrame)
# print(analysis)
root.mainloop()
# testing git