Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -443,12 +443,12 @@ def generate_personalization_prompt(key_message, approach, *selected_values):
|
|
443 |
elif approach == "None":
|
444 |
prompt += ""
|
445 |
|
446 |
-
prompt += f"Убедись, что в готовом тексте есть следующая ключевая информация: {key_message.strip()}"
|
447 |
|
448 |
if "призыва к действию" in prompt and "минимум прямых призывов к действию" in prompt:
|
449 |
prompt = re.sub(r"Убедись, что готовый текст начинается с призыва к действию с продуктом.\n", "", prompt)
|
450 |
|
451 |
-
prompt += "
|
452 |
|
453 |
return prompt.strip()
|
454 |
|
@@ -1221,30 +1221,61 @@ def check_no_dates_written_out(message):
|
|
1221 |
|
1222 |
# ФУНКЦИИ ПРОВЕРОК (КОНЕЦ)
|
1223 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1224 |
def perform_checks(message):
|
1225 |
checks = {
|
1226 |
-
"forbidden_words": check_forbidden_words
|
1227 |
-
"client_addressing": check_no_greeting
|
1228 |
-
"promises": check_no_promises
|
1229 |
-
"double_verbs": check_no_double_verbs
|
1230 |
-
"participles": check_no_participles
|
1231 |
-
"adverbial_participles": check_no_adverbial_participles
|
1232 |
-
"superlative_adjectives": check_no_superlative_adjectives
|
1233 |
-
"passive_voice": check_no_passive_voice
|
1234 |
-
"written_out_ordinals": check_no_written_out_ordinals
|
1235 |
-
"subordinate_clauses_chain": check_no_subordinate_clauses_chain
|
1236 |
-
"repeating_conjunctions": check_no_repeating_conjunctions
|
1237 |
-
"introductory_phrases": check_no_introductory_phrases
|
1238 |
-
"amplifiers": check_no_amplifiers
|
1239 |
-
"time_parasites": check_no_time_parasites
|
1240 |
-
"multiple_nouns": check_no_multiple_nouns
|
1241 |
-
"derived_prepositions": check_no_derived_prepositions
|
1242 |
-
"compound_sentences": check_no_compound_sentences
|
1243 |
-
"dates_written_out": check_no_dates_written_out
|
1244 |
}
|
1245 |
return checks
|
1246 |
|
1247 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1248 |
def format_checks(checks):
|
1249 |
translation = {
|
1250 |
"forbidden_words": "Запрещенные слова",
|
@@ -1266,7 +1297,16 @@ def format_checks(checks):
|
|
1266 |
"compound_sentences": "Сложноподчиненные предложения",
|
1267 |
"dates_written_out": "Даты прописью"
|
1268 |
}
|
1269 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1270 |
|
1271 |
|
1272 |
# Создание интерфейса Gradio
|
|
|
443 |
elif approach == "None":
|
444 |
prompt += ""
|
445 |
|
446 |
+
prompt += f"Убедись, что в готовом тексте есть следующая ключевая информация: {key_message.strip()}\n"
|
447 |
|
448 |
if "призыва к действию" in prompt and "минимум прямых призывов к действию" in prompt:
|
449 |
prompt = re.sub(r"Убедись, что готовый текст начинается с призыва к действию с продуктом.\n", "", prompt)
|
450 |
|
451 |
+
prompt += "В качестве примера хорошей адаптации текста под данные требования используй следующий текст: Оформите премиальную бизнес-карту Mastercard Preffered и наслаждайтесь бесплатным обслуживанием каждый месяц, совершая покупки на сумму от 100 000 рублей. Безлимитные платежи и мгновенные переводы на любые карты — все это доступно уже сегодня!.\n"
|
452 |
|
453 |
return prompt.strip()
|
454 |
|
|
|
1221 |
|
1222 |
# ФУНКЦИИ ПРОВЕРОК (КОНЕЦ)
|
1223 |
|
1224 |
+
def safe_check(func, message):
|
1225 |
+
try:
|
1226 |
+
return func(message)
|
1227 |
+
except Exception as e:
|
1228 |
+
# Optionally, you can log the exception here if needed
|
1229 |
+
return None # Indicate that the check could not be performed
|
1230 |
+
|
1231 |
def perform_checks(message):
|
1232 |
checks = {
|
1233 |
+
"forbidden_words": safe_check(check_forbidden_words, message),
|
1234 |
+
"client_addressing": safe_check(check_no_greeting, message),
|
1235 |
+
"promises": safe_check(check_no_promises, message),
|
1236 |
+
"double_verbs": safe_check(check_no_double_verbs, message),
|
1237 |
+
"participles": safe_check(check_no_participles, message),
|
1238 |
+
"adverbial_participles": safe_check(check_no_adverbial_participles, message),
|
1239 |
+
"superlative_adjectives": safe_check(check_no_superlative_adjectives, message),
|
1240 |
+
"passive_voice": safe_check(check_no_passive_voice, message),
|
1241 |
+
"written_out_ordinals": safe_check(check_no_written_out_ordinals, message),
|
1242 |
+
"subordinate_clauses_chain": safe_check(check_no_subordinate_clauses_chain, message),
|
1243 |
+
"repeating_conjunctions": safe_check(check_no_repeating_conjunctions, message),
|
1244 |
+
"introductory_phrases": safe_check(check_no_introductory_phrases, message),
|
1245 |
+
"amplifiers": safe_check(check_no_amplifiers, message),
|
1246 |
+
"time_parasites": safe_check(check_no_time_parasites, message),
|
1247 |
+
"multiple_nouns": safe_check(check_no_multiple_nouns, message),
|
1248 |
+
"derived_prepositions": safe_check(check_no_derived_prepositions, message),
|
1249 |
+
"compound_sentences": safe_check(check_no_compound_sentences, message),
|
1250 |
+
"dates_written_out": safe_check(check_no_dates_written_out, message)
|
1251 |
}
|
1252 |
return checks
|
1253 |
|
1254 |
|
1255 |
+
#def perform_checks(message):
|
1256 |
+
# checks = {
|
1257 |
+
# "forbidden_words": check_forbidden_words(message),
|
1258 |
+
# "client_addressing": check_no_greeting(message),
|
1259 |
+
# "promises": check_no_promises(message),
|
1260 |
+
# "double_verbs": check_no_double_verbs(message),
|
1261 |
+
# "participles": check_no_participles(message),
|
1262 |
+
# "adverbial_participles": check_no_adverbial_participles(message),
|
1263 |
+
# "superlative_adjectives": check_no_superlative_adjectives(message),
|
1264 |
+
# "passive_voice": check_no_passive_voice(message),
|
1265 |
+
# "written_out_ordinals": check_no_written_out_ordinals(message),
|
1266 |
+
# "subordinate_clauses_chain": check_no_subordinate_clauses_chain(message),
|
1267 |
+
# "repeating_conjunctions": check_no_repeating_conjunctions(message),
|
1268 |
+
# "introductory_phrases": check_no_introductory_phrases(message),
|
1269 |
+
# "amplifiers": check_no_amplifiers(message),
|
1270 |
+
# "time_parasites": check_no_time_parasites(message),
|
1271 |
+
# "multiple_nouns": check_no_multiple_nouns(message),
|
1272 |
+
# "derived_prepositions": check_no_derived_prepositions(message),
|
1273 |
+
# "compound_sentences": check_no_compound_sentences(message),
|
1274 |
+
# "dates_written_out": check_no_dates_written_out(message)
|
1275 |
+
# }
|
1276 |
+
# return checks
|
1277 |
+
|
1278 |
+
|
1279 |
def format_checks(checks):
|
1280 |
translation = {
|
1281 |
"forbidden_words": "Запрещенные слова",
|
|
|
1297 |
"compound_sentences": "Сложноподчиненные предложения",
|
1298 |
"dates_written_out": "Даты прописью"
|
1299 |
}
|
1300 |
+
formatted_results = []
|
1301 |
+
for rule, result in checks.items():
|
1302 |
+
if result is True:
|
1303 |
+
symbol = '✔️'
|
1304 |
+
elif result is False:
|
1305 |
+
symbol = '❌'
|
1306 |
+
else:
|
1307 |
+
symbol = '❓' # Indicates that the check could not be performed
|
1308 |
+
formatted_results.append(f"{translation[rule]}: {symbol}")
|
1309 |
+
return " \n".join(formatted_results)
|
1310 |
|
1311 |
|
1312 |
# Создание интерфейса Gradio
|