Spaces:
Sleeping
Sleeping
a-v-bely
commited on
Commit
·
ee27ed8
1
Parent(s):
b393949
small changes
Browse files
pages/2_👨🏫_Начало_работы.py
CHANGED
@@ -144,7 +144,7 @@ if st.session_state.get('-LOGGED_IN_BOOL-'):
|
|
144 |
key='-SAVE_IN_CLOUD-')
|
145 |
DOWNLOAD_VERSION = col2.checkbox(
|
146 |
label='**Скачать**',
|
147 |
-
value=
|
148 |
key='-DOWNLOAD_VERSION-')
|
149 |
ONLINE_TEST_VERSION = col3.checkbox(
|
150 |
label='**Онлайн тест**',
|
|
|
144 |
key='-SAVE_IN_CLOUD-')
|
145 |
DOWNLOAD_VERSION = col2.checkbox(
|
146 |
label='**Скачать**',
|
147 |
+
value=True,
|
148 |
key='-DOWNLOAD_VERSION-')
|
149 |
ONLINE_TEST_VERSION = col3.checkbox(
|
150 |
label='**Онлайн тест**',
|
utilities_language_bert/esp_main_workflow_bert.py
CHANGED
@@ -236,7 +236,7 @@ def main_workflow(
|
|
236 |
for i, sentence in enumerate(current_text_sentences):
|
237 |
for task in RESULT_TASKS:
|
238 |
if task.sentence_text == sentence:
|
239 |
-
sentence = sentence.replace(task.original_text, f'__________({tasks_counter})')
|
240 |
VARIANTS.append(task.variants)
|
241 |
tasks_counter += 1
|
242 |
TEXT_WITH_GAPS.append(sentence)
|
@@ -251,7 +251,7 @@ def main_workflow(
|
|
251 |
f'\n\n{"$" * 70}\n\n{PREPARED_TASKS["KEYS_ONLY"]}'
|
252 |
logs.update(label='Сейчас все будет готово!', state='running')
|
253 |
progress.progress(95)
|
254 |
-
save_name = save_name if save_name != '' else f'{str(datetime.datetime.now())[:-7]}_{original_text[:20]}'
|
255 |
out = {
|
256 |
'name': save_name,
|
257 |
'STUDENT_OUT': STUDENT_OUT,
|
|
|
236 |
for i, sentence in enumerate(current_text_sentences):
|
237 |
for task in RESULT_TASKS:
|
238 |
if task.sentence_text == sentence:
|
239 |
+
sentence = sentence.replace(task.original_text, f'__________({tasks_counter})', 1)
|
240 |
VARIANTS.append(task.variants)
|
241 |
tasks_counter += 1
|
242 |
TEXT_WITH_GAPS.append(sentence)
|
|
|
251 |
f'\n\n{"$" * 70}\n\n{PREPARED_TASKS["KEYS_ONLY"]}'
|
252 |
logs.update(label='Сейчас все будет готово!', state='running')
|
253 |
progress.progress(95)
|
254 |
+
save_name = save_name if save_name != '' else f'{str(datetime.datetime.now())[:-7]}_{original_text[:20]}_{level}_M3'
|
255 |
out = {
|
256 |
'name': save_name,
|
257 |
'STUDENT_OUT': STUDENT_OUT,
|
utilities_language_bert/esp_sentence_bert.py
CHANGED
@@ -175,6 +175,7 @@ class TASK:
|
|
175 |
self.tags = task_data['tags']
|
176 |
self.lemma = task_data['lemma']
|
177 |
self.gender = task_data['gender']
|
|
|
178 |
self.max_num_distractors = max_num_distractors
|
179 |
self.original_text = task_data['original_text']
|
180 |
self.sentence_text = task_data['sentence_text']
|
|
|
175 |
self.tags = task_data['tags']
|
176 |
self.lemma = task_data['lemma']
|
177 |
self.gender = task_data['gender']
|
178 |
+
self.in_summary = task_data['in_summary']
|
179 |
self.max_num_distractors = max_num_distractors
|
180 |
self.original_text = task_data['original_text']
|
181 |
self.sentence_text = task_data['sentence_text']
|
utilities_language_general/esp_constants.py
CHANGED
@@ -5,6 +5,8 @@ import streamlit as st
|
|
5 |
from pickle import load
|
6 |
from transformers import pipeline
|
7 |
from summarizer import Summarizer
|
|
|
|
|
8 |
|
9 |
|
10 |
@st.cache_resource
|
@@ -27,7 +29,7 @@ def load_spacy():
|
|
27 |
@st.cache_resource
|
28 |
def load_bert():
|
29 |
with st.spinner('Загружаю языковую модель'):
|
30 |
-
_pipeline = pipeline(task="fill-mask", model="a-v-white/bert-base-spanish-wwm-cased-finetuned-literature-pro")
|
31 |
return _pipeline
|
32 |
|
33 |
|
|
|
5 |
from pickle import load
|
6 |
from transformers import pipeline
|
7 |
from summarizer import Summarizer
|
8 |
+
from torch import cuda, device
|
9 |
+
device = device('cuda' if cuda.is_available else 'cpu')
|
10 |
|
11 |
|
12 |
@st.cache_resource
|
|
|
29 |
@st.cache_resource
|
30 |
def load_bert():
|
31 |
with st.spinner('Загружаю языковую модель'):
|
32 |
+
_pipeline = pipeline(task="fill-mask", model="a-v-white/bert-base-spanish-wwm-cased-finetuned-literature-pro", device=device)
|
33 |
return _pipeline
|
34 |
|
35 |
|
utilities_language_general/esp_utils.py
CHANGED
@@ -139,7 +139,7 @@ def get_distractors_from_model(doc, model, scaler, classifier, pos_dict:dict, ta
|
|
139 |
and distractor_lemma != lemma
|
140 |
and distractor_lemma not in lemma
|
141 |
and lemma not in distractor_lemma
|
142 |
-
and (candidate_gender == gender and level_name in ('B1', 'B2', 'C1', 'C2'))
|
143 |
and length_ratio <= max_length_ratio
|
144 |
and distractor_lemma not in global_distractors
|
145 |
and edit_distance(lemma, distractor_lemma) / ((len(lemma) + len(distractor_lemma)) / 2) > min_edit_distance_ratio)
|
@@ -224,7 +224,7 @@ def get_distractors_from_model_bert(model, scaler, classifier, pos_dict:dict, le
|
|
224 |
and decision
|
225 |
and distractor_lemma != lemma
|
226 |
and (len(_distractors) < max_num_distractors+100)
|
227 |
-
and (candidate_gender == gender and level_name in ('B1', 'B2', 'C1', 'C2'))
|
228 |
and (length_ratio <= max_length_ratio) # May be changed if case of phrases
|
229 |
and (distractor_lemma not in global_distractors)
|
230 |
and (edit_distance(lemma, distractor_lemma) # May be changed if case of phrases
|
|
|
139 |
and distractor_lemma != lemma
|
140 |
and distractor_lemma not in lemma
|
141 |
and lemma not in distractor_lemma
|
142 |
+
and (candidate_gender == gender and level_name in ('B1', 'B2', 'C1', 'C2') or level_name in ('A1', 'A2'))
|
143 |
and length_ratio <= max_length_ratio
|
144 |
and distractor_lemma not in global_distractors
|
145 |
and edit_distance(lemma, distractor_lemma) / ((len(lemma) + len(distractor_lemma)) / 2) > min_edit_distance_ratio)
|
|
|
224 |
and decision
|
225 |
and distractor_lemma != lemma
|
226 |
and (len(_distractors) < max_num_distractors+100)
|
227 |
+
and (candidate_gender == gender and level_name in ('B1', 'B2', 'C1', 'C2') or level_name in ('A1', 'A2'))
|
228 |
and (length_ratio <= max_length_ratio) # May be changed if case of phrases
|
229 |
and (distractor_lemma not in global_distractors)
|
230 |
and (edit_distance(lemma, distractor_lemma) # May be changed if case of phrases
|
utilities_language_w2v/esp_main_workflow_w2v.py
CHANGED
@@ -227,7 +227,7 @@ def main_workflow(
|
|
227 |
tasks_counter = 1
|
228 |
for i, sentence in enumerate(current_text_sentences):
|
229 |
for task in filter(lambda t: t.sentence_number == i, RESULT_TASKS):
|
230 |
-
sentence = sentence.replace(task.original_text, f'__________({tasks_counter})')
|
231 |
VARIANTS.append(task.variants)
|
232 |
tasks_counter += 1
|
233 |
TEXT_WITH_GAPS.append(sentence)
|
@@ -242,7 +242,8 @@ def main_workflow(
|
|
242 |
f'\n\n{"$" * 70}\n\n{PREPARED_TASKS["KEYS_ONLY"]}'
|
243 |
logs.update(label='Сейчас все будет готово!', state='running')
|
244 |
progress.progress(90)
|
245 |
-
|
|
|
246 |
out = {
|
247 |
'name': save_name,
|
248 |
'STUDENT_OUT': STUDENT_OUT,
|
|
|
227 |
tasks_counter = 1
|
228 |
for i, sentence in enumerate(current_text_sentences):
|
229 |
for task in filter(lambda t: t.sentence_number == i, RESULT_TASKS):
|
230 |
+
sentence = sentence.replace(task.original_text, f'__________({tasks_counter})', 1)
|
231 |
VARIANTS.append(task.variants)
|
232 |
tasks_counter += 1
|
233 |
TEXT_WITH_GAPS.append(sentence)
|
|
|
242 |
f'\n\n{"$" * 70}\n\n{PREPARED_TASKS["KEYS_ONLY"]}'
|
243 |
logs.update(label='Сейчас все будет готово!', state='running')
|
244 |
progress.progress(90)
|
245 |
+
md = {'Модель-1': 'M1', 'Модель-2': 'M2'}
|
246 |
+
save_name = save_name if save_name != '' else f'{str(datetime.datetime.now())[:-7]}_{original_text[:20]}_{level}_{md[model_name]}'
|
247 |
out = {
|
248 |
'name': save_name,
|
249 |
'STUDENT_OUT': STUDENT_OUT,
|