Spaces:
Running
Running
togokah
commited on
Commit
·
1c4aea6
1
Parent(s):
77c4a4f
Update code and models
Browse files- CHILD_phrases_s300_cw10_mc100_w4_negative5-075_mean_e20_shr.bin.gz +0 -3
- CHILD_phrases_s300_cw10_mc50_w4_negative5-075_mean_e20_shr.bin.gz +0 -3
- ALL_TOGETGER_phrases_s300_cw10_mc100_w4_negative5-075_mean_e10_shr.bin.gz → model1.gz +2 -2
- ALL_TOGETGER_phrases_s300_cw10_mc50_w4_negative5-075_mean_e20_shr.bin.gz → model2.gz +2 -2
- pages/2_👨🏫_Начало_работы.py +4 -3
- utilities_database/user_database_utils.py +1 -1
- utilities_database/user_database_widgets.py +6 -6
- utilities_language_general/rus_constants.py +2 -1
- utilities_language_w2v/rus_main_workflow_w2v.py +8 -2
CHILD_phrases_s300_cw10_mc100_w4_negative5-075_mean_e20_shr.bin.gz
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:3c63d29808c4c2b4aa72f2c5516d868d73d9e3cc439095538ef18286d5ee2851
|
3 |
-
size 37771457
|
|
|
|
|
|
|
|
CHILD_phrases_s300_cw10_mc50_w4_negative5-075_mean_e20_shr.bin.gz
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:96392e4a3873244eba861271715d681df009f4e06d9ed9c57026ab11b5b2ba83
|
3 |
-
size 61965218
|
|
|
|
|
|
|
|
ALL_TOGETGER_phrases_s300_cw10_mc100_w4_negative5-075_mean_e10_shr.bin.gz → model1.gz
RENAMED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f00a30a9b37b4c8c611aca7b2fa12c08f08769974f165b75dd3a3863f9b54f0a
|
3 |
+
size 547791266
|
ALL_TOGETGER_phrases_s300_cw10_mc50_w4_negative5-075_mean_e20_shr.bin.gz → model2.gz
RENAMED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:04a5956a39aabfc0e550614b3351752c872df92d9eea019212ec4ed36286c0a8
|
3 |
+
size 130040640
|
pages/2_👨🏫_Начало_работы.py
CHANGED
@@ -128,7 +128,7 @@ if st.session_state.get('-LOGGED_IN_BOOL-'):
|
|
128 |
key='-TARGET_WORDS_MODE-', horizontal=True)
|
129 |
DISTRACTOR_MODEL = DISTRACTOR_MODEL_COL.radio(
|
130 |
label='**Модель для выбора неправильных вариантов**',
|
131 |
-
options=['Модель-1', 'Модель-2'],
|
132 |
key='-DISTRACTOR_MODEL_MODE-', horizontal=True)
|
133 |
CEFR_NUM_DISTRACTORS_COL, UTW_COL = FORM.columns([2, 2])
|
134 |
with CEFR_NUM_DISTRACTORS_COL:
|
@@ -182,7 +182,7 @@ if st.session_state.get('-LOGGED_IN_BOOL-'):
|
|
182 |
PROGRESS_BAR_S = st.progress(0)
|
183 |
|
184 |
# Start generation process. Everything happens inside main_workflow func
|
185 |
-
if DISTRACTOR_MODEL == 'Модель-
|
186 |
from utilities_language_bert.rus_main_workflow_bert import main_workflow_bert
|
187 |
__TASK_DATA__ = main_workflow_bert(
|
188 |
file=UPLOAD_FILE,
|
@@ -211,7 +211,8 @@ if st.session_state.get('-LOGGED_IN_BOOL-'):
|
|
211 |
tw_mode_automatic_mode=TARGET_WORDS_MODE,
|
212 |
target_words=TARGET_WORDS,
|
213 |
num_distractors=NUMBER_DISTRACTORS,
|
214 |
-
save_name=USER__SAVE_IN_CLOUD_FILE_NAME
|
|
|
215 |
|
216 |
# In order to bypass further
|
217 |
USER__SAVE_IN_CLOUD_FILE_NAME = USER__SAVE_IN_CLOUD_FILE_NAME if USER__SAVE_IN_CLOUD_FILE_NAME != '' \
|
|
|
128 |
key='-TARGET_WORDS_MODE-', horizontal=True)
|
129 |
DISTRACTOR_MODEL = DISTRACTOR_MODEL_COL.radio(
|
130 |
label='**Модель для выбора неправильных вариантов**',
|
131 |
+
options=['Модель-1', 'Модель-2', 'Модель-3'],
|
132 |
key='-DISTRACTOR_MODEL_MODE-', horizontal=True)
|
133 |
CEFR_NUM_DISTRACTORS_COL, UTW_COL = FORM.columns([2, 2])
|
134 |
with CEFR_NUM_DISTRACTORS_COL:
|
|
|
182 |
PROGRESS_BAR_S = st.progress(0)
|
183 |
|
184 |
# Start generation process. Everything happens inside main_workflow func
|
185 |
+
if DISTRACTOR_MODEL == 'Модель-3':
|
186 |
from utilities_language_bert.rus_main_workflow_bert import main_workflow_bert
|
187 |
__TASK_DATA__ = main_workflow_bert(
|
188 |
file=UPLOAD_FILE,
|
|
|
211 |
tw_mode_automatic_mode=TARGET_WORDS_MODE,
|
212 |
target_words=TARGET_WORDS,
|
213 |
num_distractors=NUMBER_DISTRACTORS,
|
214 |
+
save_name=USER__SAVE_IN_CLOUD_FILE_NAME,
|
215 |
+
model_name=DISTRACTOR_MODEL)
|
216 |
|
217 |
# In order to bypass further
|
218 |
USER__SAVE_IN_CLOUD_FILE_NAME = USER__SAVE_IN_CLOUD_FILE_NAME if USER__SAVE_IN_CLOUD_FILE_NAME != '' \
|
utilities_database/user_database_utils.py
CHANGED
@@ -129,7 +129,7 @@ def check_email_exists(user_log_in_database, email_forgot_passwd: str):
|
|
129 |
"""
|
130 |
authorized_users_data = user_log_in_database.fetch({'e-mail': email_forgot_passwd}).items
|
131 |
if len(authorized_users_data) == 1:
|
132 |
-
return True, authorized_users_data['user_name']
|
133 |
return False, None
|
134 |
|
135 |
|
|
|
129 |
"""
|
130 |
authorized_users_data = user_log_in_database.fetch({'e-mail': email_forgot_passwd}).items
|
131 |
if len(authorized_users_data) == 1:
|
132 |
+
return True, authorized_users_data[0]['user_name']
|
133 |
return False, None
|
134 |
|
135 |
|
utilities_database/user_database_widgets.py
CHANGED
@@ -199,15 +199,9 @@ class LogIn:
|
|
199 |
"""
|
200 |
with st.form("Reset Password Form"):
|
201 |
email_reset_passwd = st.text_input("Email", placeholder='Please enter your email')
|
202 |
-
email_exists_check, user_name_reset_passwd = db_utils.check_email_exists(
|
203 |
-
user_log_in_database=db,
|
204 |
-
email_forgot_passwd=email_reset_passwd)
|
205 |
|
206 |
current_passwd = st.text_input("Временный пароль",
|
207 |
placeholder='Введите пароль, который вы получили в письме')
|
208 |
-
current_passwd_check = db_utils.check_current_passwd(user_log_in_database=db,
|
209 |
-
email_reset_passwd=email_reset_passwd,
|
210 |
-
current_passwd=current_passwd)
|
211 |
|
212 |
new_passwd = st.text_input("Новый пароль", placeholder='Введите новый пароль',
|
213 |
type='password')
|
@@ -218,6 +212,12 @@ class LogIn:
|
|
218 |
reset_passwd_submit_button = st.form_submit_button(label='Изменить пароль')
|
219 |
|
220 |
if reset_passwd_submit_button:
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
if not email_exists_check:
|
222 |
st.error("Пользователя с таким e-mail не существует!")
|
223 |
|
|
|
199 |
"""
|
200 |
with st.form("Reset Password Form"):
|
201 |
email_reset_passwd = st.text_input("Email", placeholder='Please enter your email')
|
|
|
|
|
|
|
202 |
|
203 |
current_passwd = st.text_input("Временный пароль",
|
204 |
placeholder='Введите пароль, который вы получили в письме')
|
|
|
|
|
|
|
205 |
|
206 |
new_passwd = st.text_input("Новый пароль", placeholder='Введите новый пароль',
|
207 |
type='password')
|
|
|
212 |
reset_passwd_submit_button = st.form_submit_button(label='Изменить пароль')
|
213 |
|
214 |
if reset_passwd_submit_button:
|
215 |
+
email_exists_check, user_name_reset_passwd = db_utils.check_email_exists(
|
216 |
+
user_log_in_database=db,
|
217 |
+
email_forgot_passwd=email_reset_passwd)
|
218 |
+
current_passwd_check = db_utils.check_current_passwd(user_log_in_database=db,
|
219 |
+
email_reset_passwd=email_reset_passwd,
|
220 |
+
current_passwd=current_passwd)
|
221 |
if not email_exists_check:
|
222 |
st.error("Пользователя с таким e-mail не существует!")
|
223 |
|
utilities_language_general/rus_constants.py
CHANGED
@@ -31,7 +31,8 @@ def load_bert():
|
|
31 |
|
32 |
nlp = load_spacy()
|
33 |
morph = load_morph()
|
34 |
-
|
|
|
35 |
|
36 |
# Upload stop list
|
37 |
stop_list = set()
|
|
|
31 |
|
32 |
nlp = load_spacy()
|
33 |
morph = load_morph()
|
34 |
+
w2v_model1_path = r'model1.gz'
|
35 |
+
w2v_model2_path = r'model2.gz'
|
36 |
|
37 |
# Upload stop list
|
38 |
stop_list = set()
|
utilities_language_w2v/rus_main_workflow_w2v.py
CHANGED
@@ -11,7 +11,8 @@ from utilities_language_general.rus_utils import prepare_tasks
|
|
11 |
from utilities_language_w2v.rus_sentence_w2v import SENTENCE
|
12 |
import utilities_language_general.rus_constants as esp_constants
|
13 |
from utilities_language_general.rus_utils import prepare_target_words
|
14 |
-
from utilities_language_general.rus_constants import
|
|
|
15 |
from utilities_language_general.rus_utils import compute_frequency_dict
|
16 |
from streamlit.runtime.uploaded_file_manager import UploadedFile
|
17 |
from utilities_language_general.rus_constants import BAD_USER_TARGET_WORDS
|
@@ -30,6 +31,7 @@ def main_workflow_w2v(
|
|
30 |
target_words: str,
|
31 |
num_distractors: int,
|
32 |
save_name: str,
|
|
|
33 |
global_bad_target_words=BAD_USER_TARGET_WORDS):
|
34 |
"""
|
35 |
This is the main course of the program.
|
@@ -49,6 +51,7 @@ def main_workflow_w2v(
|
|
49 |
:param num_distractors: how many distractors does the user want the task to contain
|
50 |
:param save_name: user specifies name to save file in cloud
|
51 |
:param global_bad_target_words:global_bad_target_words
|
|
|
52 |
:return: Dictionary with output data: filename, amount_mode, text_with_gaps, tasks_as_list, correct_answers,
|
53 |
student_out, teacher_out, total_out, original_text
|
54 |
"""
|
@@ -61,7 +64,10 @@ def main_workflow_w2v(
|
|
61 |
MAX_FREQUENCY = 0
|
62 |
|
63 |
# Define which model is used for distractor generation
|
64 |
-
|
|
|
|
|
|
|
65 |
|
66 |
# Get input text
|
67 |
if file is not None:
|
|
|
11 |
from utilities_language_w2v.rus_sentence_w2v import SENTENCE
|
12 |
import utilities_language_general.rus_constants as esp_constants
|
13 |
from utilities_language_general.rus_utils import prepare_target_words
|
14 |
+
from utilities_language_general.rus_constants import w2v_model1_path
|
15 |
+
from utilities_language_general.rus_constants import w2v_model2_path
|
16 |
from utilities_language_general.rus_utils import compute_frequency_dict
|
17 |
from streamlit.runtime.uploaded_file_manager import UploadedFile
|
18 |
from utilities_language_general.rus_constants import BAD_USER_TARGET_WORDS
|
|
|
31 |
target_words: str,
|
32 |
num_distractors: int,
|
33 |
save_name: str,
|
34 |
+
model_name: str,
|
35 |
global_bad_target_words=BAD_USER_TARGET_WORDS):
|
36 |
"""
|
37 |
This is the main course of the program.
|
|
|
51 |
:param num_distractors: how many distractors does the user want the task to contain
|
52 |
:param save_name: user specifies name to save file in cloud
|
53 |
:param global_bad_target_words:global_bad_target_words
|
54 |
+
:param model_name
|
55 |
:return: Dictionary with output data: filename, amount_mode, text_with_gaps, tasks_as_list, correct_answers,
|
56 |
student_out, teacher_out, total_out, original_text
|
57 |
"""
|
|
|
64 |
MAX_FREQUENCY = 0
|
65 |
|
66 |
# Define which model is used for distractor generation
|
67 |
+
if model_name == 'Модель-1':
|
68 |
+
mask_filler = load_w2v(w2v_model1_path)
|
69 |
+
else:
|
70 |
+
mask_filler = load_w2v(w2v_model2_path)
|
71 |
|
72 |
# Get input text
|
73 |
if file is not None:
|