File size: 18,412 Bytes
d0f716d
 
 
 
 
 
 
aa2aec1
 
d0f716d
aa2aec1
6de61f5
 
0e30f40
d0f716d
 
 
8f52d54
 
 
 
 
d0f716d
8f52d54
 
d0f716d
 
8f52d54
 
 
 
1a72a47
1bf4da3
 
8f52d54
1bf4da3
1a72a47
1bf4da3
 
 
8f52d54
1bf4da3
 
 
 
 
 
 
 
 
 
 
8f52d54
1bf4da3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c0f084a
 
8f52d54
1bf4da3
 
c0f084a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8f52d54
c0f084a
 
 
 
 
 
 
 
 
 
 
 
 
8f52d54
c0f084a
 
 
 
 
 
 
 
 
 
 
 
 
 
8f52d54
c0f084a
 
 
 
 
 
 
 
 
 
 
 
 
 
8f52d54
c0f084a
 
 
 
 
 
 
 
 
 
 
 
 
 
8f52d54
c0f084a
 
 
 
 
 
 
 
 
 
 
 
 
 
8f52d54
c0f084a
 
 
 
 
aa2aec1
 
8f52d54
1bf4da3
 
0e30f40
b29eeee
aa2aec1
 
 
 
c0f084a
aa2aec1
 
8f52d54
aa2aec1
 
 
 
 
 
 
 
8f52d54
aa2aec1
 
0e30f40
 
 
 
 
 
c0f084a
 
 
 
 
 
 
 
 
0e30f40
 
 
 
506641f
 
0e30f40
 
 
8f52d54
1bf4da3
 
0e30f40
 
 
 
 
 
 
 
c0f084a
0e30f40
 
8f52d54
0e30f40
 
 
 
 
 
 
 
 
c0f084a
0e30f40
 
8f52d54
0e30f40
 
 
 
 
 
 
 
 
c0f084a
0e30f40
 
8f52d54
0e30f40
 
 
 
 
 
 
 
 
c0f084a
0e30f40
 
8f52d54
0e30f40
 
 
 
 
 
 
 
 
c0f084a
0e30f40
 
8f52d54
0e30f40
 
 
 
 
 
 
 
506641f
 
 
 
 
 
c0f084a
0e30f40
 
8f52d54
0e30f40
 
 
c0f084a
 
 
 
 
 
 
 
 
 
 
 
 
d02f294
c0f084a
87a92fb
 
 
 
 
 
 
 
 
 
 
 
 
d02f294
87a92fb
c0f084a
 
 
d02f294
1bf4da3
 
c0f084a
 
 
 
 
 
 
 
 
1bf4da3
c0f084a
fe19555
 
 
 
 
c0f084a
 
 
fe19555
 
 
 
 
 
c0f084a
 
 
d02f294
c0f084a
 
 
 
1bf4da3
c0f084a
 
 
 
 
 
 
d02f294
c0f084a
 
 
 
 
 
 
 
 
 
 
 
d02f294
c0f084a
 
 
 
 
 
 
 
 
aa2aec1
 
 
 
 
1bf4da3
 
0e30f40
aa2aec1
0e30f40
 
 
 
 
 
c0f084a
 
 
 
 
 
 
 
 
aa2aec1
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
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
"""
File: practical_subtasks.py
Author: Elena Ryumina and Dmitry Ryumin
Description: Event handler for Gradio app to filter practical subtasks based on selected practical subtasks.
License: MIT License
"""

import gradio as gr

# Importing necessary components for the Gradio app
from app.config import config_data
from app.utils import read_csv_file, get_language_settings
from app.data_init import weights_professions, interactive_professions
from app.components import number_create_ui, dropdown_create_ui


def event_handler_practical_subtasks(
    language,
    type_modes,
    practical_tasks,
    practical_subtasks,
    practical_subtasks_selected,
):
    lang_id, _ = get_language_settings(language)

    practical_subtasks_selected[practical_tasks] = practical_subtasks

    visible_subtasks = (
        True if type_modes == config_data.Settings_TYPE_MODES[0] else False
    )

    if practical_subtasks.lower() == "16 personality types of mbti":
        return (
            practical_subtasks_selected,
            gr.Column(visible=visible_subtasks),
            dropdown_create_ui(
                label=f"Potential candidates by Personality Type of MBTI ({len(config_data.Settings_DROPDOWN_MBTI)})",
                info=config_data.InformationMessages_DROPDOWN_MBTI_INFO,
                choices=config_data.Settings_DROPDOWN_MBTI,
                value=config_data.Settings_DROPDOWN_MBTI[0],
                visible=visible_subtasks,
                elem_classes="dropdown-container",
            ),
            number_create_ui(
                value=0.5,
                minimum=0.0,
                maximum=1.0,
                step=0.01,
                label=config_data.Labels_THRESHOLD_MBTI_LABEL,
                info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(0, 1.0),
                show_label=True,
                interactive=True,
                visible=visible_subtasks,
                render=True,
                elem_classes="number-container",
            ),
            number_create_ui(visible=False),
            dropdown_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            dropdown_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
        )
    elif practical_subtasks.lower() == "professional groups":
        return (
            practical_subtasks_selected,
            gr.Column(visible=visible_subtasks),
            dropdown_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            dropdown_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            dropdown_create_ui(
                label=f"Potential candidates by professional responsibilities ({len(config_data.Settings_DROPDOWN_CANDIDATES)})",
                info=config_data.InformationMessages_DROPDOWN_CANDIDATES_INFO,
                choices=config_data.Settings_DROPDOWN_CANDIDATES,
                value=config_data.Settings_DROPDOWN_CANDIDATES[0],
                visible=visible_subtasks,
                elem_classes="dropdown-container",
            ),
            number_create_ui(
                value=weights_professions[0],
                minimum=config_data.Values_0_100[0],
                maximum=config_data.Values_0_100[1],
                step=1,
                label=config_data.Labels_NUMBER_IMPORTANCE_OPE_LABEL,
                info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(
                    config_data.Values_0_100[0], config_data.Values_0_100[1]
                ),
                show_label=True,
                interactive=interactive_professions,
                visible=visible_subtasks,
                render=True,
                elem_classes="number-container",
            ),
            number_create_ui(
                value=weights_professions[1],
                minimum=config_data.Values_0_100[0],
                maximum=config_data.Values_0_100[1],
                step=1,
                label=config_data.Labels_NUMBER_IMPORTANCE_CON_LABEL,
                info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(
                    config_data.Values_0_100[0], config_data.Values_0_100[1]
                ),
                show_label=True,
                interactive=interactive_professions,
                visible=visible_subtasks,
                render=True,
                elem_classes="number-container",
            ),
            number_create_ui(
                value=weights_professions[2],
                minimum=config_data.Values_0_100[0],
                maximum=config_data.Values_0_100[1],
                step=1,
                label=config_data.Labels_NUMBER_IMPORTANCE_EXT_LABEL,
                info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(
                    config_data.Values_0_100[0], config_data.Values_0_100[1]
                ),
                show_label=True,
                interactive=interactive_professions,
                visible=visible_subtasks,
                render=True,
                elem_classes="number-container",
            ),
            number_create_ui(
                value=weights_professions[3],
                minimum=config_data.Values_0_100[0],
                maximum=config_data.Values_0_100[1],
                step=1,
                label=config_data.Labels_NUMBER_IMPORTANCE_AGR_LABEL,
                info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(
                    config_data.Values_0_100[0], config_data.Values_0_100[1]
                ),
                show_label=True,
                interactive=interactive_professions,
                visible=visible_subtasks,
                render=True,
                elem_classes="number-container",
            ),
            number_create_ui(
                value=weights_professions[4],
                minimum=config_data.Values_0_100[0],
                maximum=config_data.Values_0_100[1],
                step=1,
                label=config_data.Labels_NUMBER_IMPORTANCE_NNEU_LABEL,
                info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(
                    config_data.Values_0_100[0], config_data.Values_0_100[1]
                ),
                show_label=True,
                interactive=interactive_professions,
                visible=visible_subtasks,
                render=True,
                elem_classes="number-container",
            ),
        )
    elif practical_subtasks.lower() == "professional skills":
        return (
            practical_subtasks_selected,
            gr.Column(visible=visible_subtasks),
            dropdown_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(
                value=0.45,
                minimum=0.0,
                maximum=1.0,
                step=0.01,
                label=config_data.Labels_THRESHOLD_PROFESSIONAL_SKILLS_LABEL,
                info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(0, 1.0),
                show_label=True,
                interactive=True,
                visible=visible_subtasks,
                render=True,
                elem_classes="number-container",
            ),
            dropdown_create_ui(
                label=f"Professional skills ({len(config_data.Settings_DROPDOWN_PROFESSIONAL_SKILLS)})",
                info=config_data.InformationMessages_DROPDOWN_PROFESSIONAL_SKILLS_INFO,
                choices=config_data.Settings_DROPDOWN_PROFESSIONAL_SKILLS,
                value=config_data.Settings_DROPDOWN_PROFESSIONAL_SKILLS[0],
                visible=visible_subtasks,
                elem_classes="dropdown-container",
            ),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            dropdown_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
        )
    elif (
        practical_subtasks.lower() == "finding a suitable junior colleague"
        or practical_subtasks.lower() == "finding a suitable senior colleague"
        or practical_subtasks.lower()
        == "finding a suitable colleague by personality types"
    ):
        return (
            practical_subtasks_selected,
            gr.Column(visible=visible_subtasks),
            dropdown_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            dropdown_create_ui(visible=False),
            number_create_ui(
                value=config_data.Values_TARGET_SCORES[0],
                minimum=0.0,
                maximum=1.0,
                step=0.000001,
                label=config_data.Labels_TARGET_SCORE_OPE_LABEL,
                info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(0, 1.0),
                show_label=True,
                interactive=True,
                visible=visible_subtasks,
                render=True,
                elem_classes="number-container",
            ),
            number_create_ui(
                value=config_data.Values_TARGET_SCORES[1],
                minimum=0.0,
                maximum=1.0,
                step=0.000001,
                label=config_data.Labels_TARGET_SCORE_CON_LABEL,
                info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(0, 1.0),
                show_label=True,
                interactive=True,
                visible=visible_subtasks,
                render=True,
                elem_classes="number-container",
            ),
            number_create_ui(
                value=config_data.Values_TARGET_SCORES[2],
                minimum=0.0,
                maximum=1.0,
                step=0.000001,
                label=config_data.Labels_TARGET_SCORE_EXT_LABEL,
                info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(0, 1.0),
                show_label=True,
                interactive=True,
                visible=visible_subtasks,
                render=True,
                elem_classes="number-container",
            ),
            number_create_ui(
                value=config_data.Values_TARGET_SCORES[3],
                minimum=0.0,
                maximum=1.0,
                step=0.000001,
                label=config_data.Labels_TARGET_SCORE_AGR_LABEL,
                info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(0, 1.0),
                show_label=True,
                interactive=True,
                visible=visible_subtasks,
                render=True,
                elem_classes="number-container",
            ),
            number_create_ui(
                value=config_data.Values_TARGET_SCORES[4],
                minimum=0.0,
                maximum=1.0,
                step=0.000001,
                label=config_data.Labels_TARGET_SCORE_NNEU_LABEL,
                info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(0, 1.0),
                show_label=True,
                interactive=True,
                visible=visible_subtasks,
                render=True,
                elem_classes="number-container",
            ),
            number_create_ui(
                value=0.5,
                minimum=0.0,
                maximum=1.0,
                step=0.01,
                label=(
                    config_data.Labels_THRESHOLD_TARGET_SCORE_LABEL
                    if practical_subtasks.lower()
                    == "finding a suitable colleague by personality types"
                    else config_data.Labels_EQUAL_COEFFICIENT_LABEL
                ),
                info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(0, 1.0),
                show_label=True,
                interactive=True,
                visible=visible_subtasks,
                render=True,
                elem_classes="number-container",
            ),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            dropdown_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
        )
    elif (
        practical_subtasks.lower() == "car characteristics"
        or practical_subtasks.lower() == "mobile device application categories"
        or practical_subtasks.lower() == "clothing styles"
    ):
        if practical_subtasks.lower() == "car characteristics":

            df_correlation_coefficients = read_csv_file(
                config_data.Links_CAR_CHARACTERISTICS,
                ["Trait", "Style and performance", "Safety and practicality"],
            )

        elif practical_subtasks.lower() == "mobile device application categories":

            df_correlation_coefficients = read_csv_file(
                config_data.Links_MDA_CATEGORIES
            )

        elif practical_subtasks.lower() == "clothing styles":
            df_correlation_coefficients = read_csv_file(config_data.Links_CLOTHING_SC)

        return (
            practical_subtasks_selected,
            gr.Column(visible=visible_subtasks),
            dropdown_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            dropdown_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(
                value=1,
                minimum=1,
                maximum=(
                    df_correlation_coefficients.columns.size
                    if practical_subtasks.lower() == "car characteristics"
                    else df_correlation_coefficients.columns.size - 1
                ),
                step=1,
                label=config_data.Labels_NUMBER_PRIORITY_LABEL,
                info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(
                    1,
                    (
                        df_correlation_coefficients.columns.size
                        if practical_subtasks.lower() == "car characteristics"
                        else df_correlation_coefficients.columns.size - 1
                    ),
                ),
                show_label=True,
                interactive=True,
                visible=visible_subtasks,
                render=True,
                elem_classes="number-container",
            ),
            number_create_ui(
                value=1,
                minimum=1,
                maximum=5,
                step=1,
                label=config_data.Labels_NUMBER_IMPORTANCE_TRAITS_LABEL,
                info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(1, 5),
                show_label=True,
                interactive=True,
                visible=visible_subtasks,
                render=True,
                elem_classes="number-container",
            ),
            number_create_ui(
                value=0.55,
                minimum=0.0,
                maximum=1.0,
                step=0.01,
                label=config_data.Labels_THRESHOLD_CONSUMER_PREFERENCES_LABEL,
                info=config_data.InformationMessages_VALUE_FROM_TO_INFO.format(0, 1.0),
                show_label=True,
                interactive=True,
                visible=visible_subtasks,
                render=True,
                elem_classes="number-container",
            ),
            dropdown_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
        )
    else:
        return (
            practical_subtasks_selected,
            gr.Column(visible=False),
            dropdown_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            dropdown_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            dropdown_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
            number_create_ui(visible=False),
        )