-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.rb
executable file
·365 lines (305 loc) · 12.3 KB
/
main.rb
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
#!/usr/bin/env ruby
# encoding: UTF-8
#
# main.rb
#
# Copyright 2017 Pier Alberto <pieralbertopierini@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
#
require 'tk'
require 'tkextlib/tile'
require_relative 'src/words_preprocessing.rb'
require_relative 'src/words_analyser.rb'
require_relative 'src/skills_analyser.rb'
require_relative 'src/list_directory.rb'
# Start Root window mainloop
$root = TkRoot.new( :title => "AutoResume", :width => 640, :height => 480)
# Contents
content = Tk::Tile::Frame.new($root) {padding "3 3 3 3"}
content.grid :sticky => 'nsew'
#config_column = TkGrid.columnconfigure $root, 0, :weight => 1
#config_row = TkGrid.rowconfigure $root, 0, :weight => 1
resize_window = Tk::Tile::SizeGrip.new($root)
resize_window.grid :column => 999, :row => 999, :sticky => 'nsew'
#TkOption.add '*tearOff', 0
# Variables
$testVariable_one = TkVariable.new
$testVariable_two = TkVariable.new
directory_skills = "skills/*"
# Menu Actions
menu_click = Proc.new {
Tk.messageBox(
'type' => "ok",
'icon' => "info",
'title' => "Message",
'message' => "Function not supported"
)
}
## TODO: open and save file
ar_openfile = Proc.new {
Tk.getOpenFile
}
ar_savefile = Proc.new {
Tk.getSaveFile
}
# File menu
file_menu = TkMenu.new($root, 'tearoff' => false)
file_menu.add('command',
'label' => "New...",
'command' => menu_click,
'underline' => 0)
$root.bind('Control-N', proc {openDocument})
file_menu.add('command',
'label' => "Open...",
'command' => ar_openfile,
'underline' => 0,
'accel' =>'Ctrl-o')
$root.bind('Control-o', proc {openDocument})
file_menu.add('command',
'label' => "Close",
'command' => menu_click,
'underline' => 0)
$root.bind('Control-c', proc {openDocument})
file_menu.add('separator')
file_menu.add('command',
'label' => "Save",
'command' => ar_savefile,
'underline' => 0)
$root.bind('Control-S', proc {openDocument})
file_menu.add('command',
'label' => "Save As...",
'command' => menu_click,
'underline' => 5)
file_menu.add('separator')
file_menu.add('command',
'label' => "Quit",
'command' => proc { exit },
'underline' => 0,
'accel' => 'Ctrl-q')
$root.bind('Control-q', proc {exit})
# Edit menu
edit_menu = TkMenu.new($root, 'tearoff' => false)
edit_menu.add('command',
'label' => "New...",
'command' => menu_click,
'underline' => 0)
# Help menu
help_menu = TkMenu.new($root, 'tearoff' => false)
help_menu.add('command',
'label' => "Help",
'command' => menu_click,
'underline' => 0)
help_menu.add('command',
'label' => "About",
'command' => proc {Tk::messageBox :message => 'This pice of software is Developed by Pier Alberto Pierini'},
'underline' => 0)
# Add on the menu bar components
menu_bar = TkMenu.new
menu_bar.add('cascade',
'menu' => file_menu,
'label' => "File")
menu_bar.add('cascade',
'menu' => edit_menu,
'label' => "Edit")
menu_bar.add('cascade',
'menu' => help_menu,
'label' => "Help")
$root.menu(menu_bar)
# Start Notebook
notebook = Tk::Tile::Notebook.new($root)
notebook.grid :column => 0, :row => 0, :sticky => 'nsew'
f1 = TkFrame.new(notebook)
f2 = TkFrame.new(notebook)
f3 = TkFrame.new(notebook)
f4 = TkFrame.new(notebook)
f5 = TkFrame.new(notebook)
f6 = TkFrame.new(notebook)
f7 = TkFrame.new(notebook)
f8 = TkFrame.new(notebook)
notebook.add f1, :text => 'Stats', :state => 'normal'
notebook.add f2, :text => 'Soft Skills', :state => 'normal'
notebook.add f3, :text => 'Hard Skills', :state => 'normal'
#TODO: notebook to add for filter_list exceptions
notebook.add f4, :text => 'Technical Knowledge', :state => 'disabled'
notebook.add f5, :text => 'Volunteer Experiences & Causes', :state => 'disabled'
notebook.add f6, :text => 'Employment History', :state => 'disabled'
notebook.add f7, :text => 'Education and Training', :state => 'disabled'
notebook.add f8, :text => 'Exceptions', :state => 'disabled'
# F1 (Stats)
#Variables for the words Preprocessing and Analyser
filter_text = WordsPreprocessing.to_words(File.read('exceptions/filter_list.txt'))
# variable to change in automatic the labels
$resultsResume = TkVariable.new
$resultsJob = TkVariable.new
# Lable and Combobox
label_numberwords = Tk::Tile::Label.new(f1) {text 'Number Words to show:'}
label_numberwords.grid :row => 0, :column => 0, :sticky => 'e'
$number_words_var = TkVariable.new
numberwords = Tk::Tile::Combobox.new(f1) { textvariable $number_words_var }
numberwords.grid :row => 0, :column => 2, :sticky => 'w'
numberwords.bind("<ComboboxSelected>") { $number_words = $number_words_var.to_i }
numberwords.values = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
my_resume = TkText.new(f1) {width 40; height 25; borderwidth 1; wrap 'word'; font TkFont.new('times 10 italic')}
my_resume.grid :row => 1, :column => 0
my_resume.insert(1.0, "here is my text to insert")
scroll_bar_resume = Tk::Tile::Scrollbar.new(f1, 'command' => proc { |*args| my_resume.yview *args })
scroll_bar_resume.grid :row => 1, :column => 1, :sticky => 'ns'
my_resume.yscrollcommand(proc { |first,last| scroll_bar_resume.set(first,last) })
Tk::Tile::Button.new(f1) do
text 'Clear'
command do
my_resume.delete("1.0", 'end')
end
grid( :column => 0, :row => 2, :sticky => 'w')
end
Tk::Tile::Button.new(f1) do
text 'Count Words'
command proc{resume_text = WordsPreprocessing.to_words(my_resume.get("1.0", 'end'));
resume_analysed = WordsAnalyser.new(resume_text, filter_text);
$resultsResume.value = resume_analysed.text_list_highest($number_words)}
grid( :column => 0, :row => 2, :sticky => 'e')
end
label_1 = Tk::Tile::Label.new(f1){textvariable $resultsResume}
label_1.grid :row => 1, :column => 4
job_application = TkText.new(f1) {width 40; height 25; borderwidth 1; wrap 'word'; font TkFont.new('times 10 italic')}
job_application.grid :row => 1, :column => 2
job_application.insert(1.0, 'Paste job post')
scroll_bar_job_application = Tk::Tile::Scrollbar.new(f1, 'command' => proc { |*args| job_application.yview *args })
scroll_bar_job_application.grid :column => 3, :row => 1, :sticky => 'ns'
job_application.yscrollcommand(proc { |first,last| scroll_bar_job_application.set(first,last) })
Tk::Tile::Button.new(f1) do
text 'Clear'
command do
job_application.delete("1.0", 'end')
end
grid( :column => 2, :row => 2, :sticky => 'w')
end
label_2 = Tk::Tile::Label.new(f1){textvariable $resultsJob}
label_2.grid :column => 6, :row => 1
Tk::Tile::Button.new(f1) do
text 'Count Words'
command proc{job_text = WordsPreprocessing.to_words(job_application.get("1.0", 'end'));
job_analysed = WordsAnalyser.new(job_text, filter_text);
$resultsJob.value = job_analysed.text_list_highest($number_words)}
grid( :column => 2, :row => 2, :sticky => 'e')
end
# F2 (Soft Skill)
label_numberwords = Tk::Tile::Label.new(f2) {text 'Soft Skill file:'}
label_numberwords.grid :row => 0, :column => 0, :sticky => 'e'
# TODO: Read directory for the list of filter_list
$skills_soft_list_var = TkVariable.new
skills_list = Tk::Tile::Combobox.new(f2) { textvariable $skills_soft_list_var}
skills_list.grid :row => 0, :column => 1
skills_list.bind("<ComboboxSelected>") { $skills_soft_list_var }
skills_file = ListDirectory.new(directory_skills)
skills_list.values = skills_file.links_list
Tk::Tile::Button.new(f2) do
text 'Populate the entries'
command proc{}
grid( :column => 2, :row => 0, :sticky => 'w')
end
# Add Soft skills
label_add_skill = Tk::Tile::Label.new(f2) {text 'Add Soft Skill:'}
label_add_skill.grid :row => 1, :column => 0, :sticky => 'e'
skills_list = Tk::Tile::Combobox.new(f2) { textvariable }
skills_list.grid :row => 1, :column => 1
#skills_list.bind("<ComboboxSelected>") { $number_words = $number_words_var.to_i }
skills_list.values = [ Dir["skills/*"] ]
Tk::Tile::Button.new(f2) do
text 'Add Soft Skill'
command proc{}
grid( :column => 2, :row => 1, :sticky => 'w')
end
# Delete Soft skills
label_delete_skill = Tk::Tile::Label.new(f2) {text 'Delete Soft Skill:'}
label_delete_skill.grid :row => 2, :column => 0, :sticky => 'e'
skills_list = Tk::Tile::Combobox.new(f2) { textvariable }
skills_list.grid :row => 2, :column => 1
#skills_list.bind("<ComboboxSelected>") { $number_words = $number_words_var.to_i }
skills_list.values = [ Dir["skills/*"] ]
Tk::Tile::Button.new(f2) do
text 'Delete Soft Skill'
command proc{}
grid( :column => 2, :row => 2, :sticky => 'w')
end
# Skills list
label_skills_comlumn0 = Tk::Tile::Label.new(f2){textvariable }
label_skills_comlumn0.grid :column => 0, :row => 3
label_skills_comlumn1 = Tk::Tile::Label.new(f2){textvariable }
label_skills_comlumn1.grid :column => 1, :row => 3
label_skills_comlumn2 = Tk::Tile::Label.new(f2){textvariable }
label_skills_comlumn2.grid :column => 2, :row => 3
label_skills_comlumn3 = Tk::Tile::Label.new(f2){textvariable }
label_skills_comlumn3.grid :column => 3, :row => 3
label_skills_comlumn4 = Tk::Tile::Label.new(f2){textvariable }
label_skills_comlumn4.grid :column => 4, :row => 3
TkWinfo.children(f2).each {|w| TkGrid.configure w, :padx => 5, :pady => 5}
# F3 (Hard Skill)
# TODO: Hard skills to modify
label_numberwords = Tk::Tile::Label.new(f3) {text 'Hard Skill file:'}
label_numberwords.grid :row => 0, :column => 0, :sticky => 'e'
# TODO: Read directory for the list of filter_list
$skills_hard_list_var = TkVariable.new
skills_list = Tk::Tile::Combobox.new(f3) { textvariable $skills_hard_list_var }
skills_list.grid :row => 0, :column => 1
skills_list.bind("<ComboboxSelected>") { $skills_hard_list_var }
skills_file = ListDirectory.new(directory_skills)
skills_list.values = [ skills_file.links_list ]
Tk::Tile::Button.new(f3) do
text 'Populate entries'
command proc{}
grid( :column => 2, :row => 0, :sticky => 'w')
end
# Add Hard skills
label_add_skill = Tk::Tile::Label.new(f3) {text 'Add Hard Skill:'}
label_add_skill.grid :row => 1, :column => 0, :sticky => 'e'
skills_list = Tk::Tile::Combobox.new(f3) { textvariable }
skills_list.grid :row => 1, :column => 1
#skills_list.bind("<ComboboxSelected>") { $number_words = $number_words_var.to_i }
skills_list.values = [ Dir["skills/*"] ]
Tk::Tile::Button.new(f3) do
text 'Add Hard Skill'
command proc{}
grid( :column => 2, :row => 1, :sticky => 'w')
end
# Delete Hard skills
label_delete_skill = Tk::Tile::Label.new(f3) {text 'Delete Hard Skill:'}
label_delete_skill.grid :row => 2, :column => 0, :sticky => 'e'
skills_list = Tk::Tile::Combobox.new(f3) { textvariable }
skills_list.grid :row => 2, :column => 1
#skills_list.bind("<ComboboxSelected>") { $number_words = $number_words_var.to_i }
skills_list.values = [ Dir["skills/*"] ]
Tk::Tile::Button.new(f3) do
text 'Delete Hard Skill'
command proc{}
grid( :column => 2, :row => 2, :sticky => 'w')
end
# Skills list
label_skills_comlumn0 = Tk::Tile::Label.new(f3){textvariable }
label_skills_comlumn0.grid :column => 0, :row => 3
label_skills_comlumn1 = Tk::Tile::Label.new(f3){textvariable }
label_skills_comlumn1.grid :column => 1, :row => 3
label_skills_comlumn2 = Tk::Tile::Label.new(f3){textvariable }
label_skills_comlumn2.grid :column => 2, :row => 3
label_skills_comlumn3 = Tk::Tile::Label.new(f3){textvariable }
label_skills_comlumn3.grid :column => 3, :row => 3
label_skills_comlumn4 = Tk::Tile::Label.new(f3){textvariable }
label_skills_comlumn4.grid :column => 4, :row => 3
TkWinfo.children(f3).each {|w| TkGrid.configure w, :padx => 5, :pady => 5}
# End root mainloop
Tk.mainloop