Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -11,7 +11,7 @@ from openpyxl.utils import get_column_letter
|
|
11 |
from openpyxl.styles import Alignment
|
12 |
import base64
|
13 |
from together import Together
|
14 |
-
import
|
15 |
import pymorphy3
|
16 |
import re
|
17 |
import string
|
@@ -25,7 +25,7 @@ import numpy as np
|
|
25 |
from mistralai import Mistral
|
26 |
|
27 |
|
28 |
-
#morph =
|
29 |
morph = pymorphy3.MorphAnalyzer()
|
30 |
|
31 |
# Установка ключа API для OpenAI, GigaChat и Mistral
|
@@ -464,7 +464,7 @@ def update_download_link():
|
|
464 |
|
465 |
|
466 |
def correct_dash_usage(text):
|
467 |
-
morph =
|
468 |
# Step 1: Replace any dash with long dash if surrounded by spaces
|
469 |
text = re.sub(r'\s[-–—]\s', ' — ', text)
|
470 |
|
@@ -526,7 +526,7 @@ def correct_dash_usage(text):
|
|
526 |
text = re.sub(r'\bею\b', 'ей', text, flags=re.IGNORECASE)
|
527 |
|
528 |
def restore_yo(text):
|
529 |
-
morph =
|
530 |
words = text.split()
|
531 |
restored_words = []
|
532 |
|
@@ -1793,7 +1793,7 @@ def perform_analysis_with_yield(
|
|
1793 |
# 1. Запрещенные слова
|
1794 |
|
1795 |
def check_forbidden_words(message):
|
1796 |
-
morph =
|
1797 |
|
1798 |
# Перечень запрещённых слов и фраз
|
1799 |
forbidden_patterns = [
|
@@ -1827,7 +1827,7 @@ def check_forbidden_words(message):
|
|
1827 |
# 2 и #3. Обращение к клиенту и приветствие клиента
|
1828 |
|
1829 |
def check_no_greeting(message):
|
1830 |
-
morph =
|
1831 |
# Список типичных обращений и приветствий
|
1832 |
greeting_patterns = [
|
1833 |
r"привет\b", r"здравствуй", r"добрый\s(день|вечер|утро)",
|
@@ -1847,7 +1847,7 @@ def check_no_greeting(message):
|
|
1847 |
# 4. Обещания и гарантии
|
1848 |
|
1849 |
def check_no_promises(message):
|
1850 |
-
morph =
|
1851 |
promise_patterns = [
|
1852 |
"обещать", "обещание", "гарантировать", "обязаться", "обязать", "обязательство", "обязательный"
|
1853 |
]
|
@@ -1863,7 +1863,7 @@ def check_no_promises(message):
|
|
1863 |
# 5. Составные конструкции из двух глаголов
|
1864 |
|
1865 |
def check_no_double_verbs(message):
|
1866 |
-
morph =
|
1867 |
# Разделяем текст по пробелам и знакам препинания
|
1868 |
words = re.split(r'\s+|[.!?]', message)
|
1869 |
morphs = [morph.parse(word)[0] for word in words]
|
@@ -1881,7 +1881,7 @@ def check_no_double_verbs(message):
|
|
1881 |
# 6. Причастия и причастные обороты
|
1882 |
|
1883 |
def check_no_participles(message):
|
1884 |
-
morph =
|
1885 |
words = message.split()
|
1886 |
morphs = [morph.parse(word)[0] for word in words]
|
1887 |
|
@@ -1893,7 +1893,7 @@ def check_no_participles(message):
|
|
1893 |
# 7. Деепричастия и деепричастные обороты
|
1894 |
|
1895 |
def check_no_adverbial_participles(message):
|
1896 |
-
morph =
|
1897 |
words = message.split()
|
1898 |
morphs = [morph.parse(word)[0] for word in words]
|
1899 |
|
@@ -1905,7 +1905,7 @@ def check_no_adverbial_participles(message):
|
|
1905 |
# 8. Превосходная степень прилагательных
|
1906 |
|
1907 |
def check_no_superlative_adjectives(message):
|
1908 |
-
morph =
|
1909 |
words = message.split()
|
1910 |
morphs = [morph.parse(word)[0] for word in words]
|
1911 |
|
@@ -1917,7 +1917,7 @@ def check_no_superlative_adjectives(message):
|
|
1917 |
# 9. Страдательный залог
|
1918 |
|
1919 |
def check_no_passive_voice(message):
|
1920 |
-
morph =
|
1921 |
words = message.split()
|
1922 |
morphs = [morph.parse(word)[0] for word in words]
|
1923 |
|
@@ -1929,7 +1929,7 @@ def check_no_passive_voice(message):
|
|
1929 |
# 10. Порядковые числительные от 10 прописью
|
1930 |
|
1931 |
def check_no_written_out_ordinals(message):
|
1932 |
-
morph =
|
1933 |
ordinal_words = [
|
1934 |
"десятый", "одиннадцатый", "двенадцатый", "тринадцатый", "четырнадцатый", "пятнадцатый",
|
1935 |
"шестнадцатый", "семнадцатый", "восемнадцатый", "девятнадцатый", "двадцатый"
|
@@ -2018,7 +2018,7 @@ def check_no_time_parasites(message):
|
|
2018 |
def check_no_multiple_nouns(message):
|
2019 |
noun_count = 0
|
2020 |
words = re.split(r'\s+|[.!?]', message) # Разбиваем по пробелам и знакам препинания
|
2021 |
-
morph =
|
2022 |
|
2023 |
for word in words:
|
2024 |
parsed_word = morph.parse(word)[0]
|
@@ -2088,7 +2088,7 @@ def check_no_dates_written_out(message):
|
|
2088 |
# Доп правило. Повторы слов
|
2089 |
|
2090 |
def check_no_word_repetitions(message):
|
2091 |
-
morph =
|
2092 |
|
2093 |
# Список союзов и предлогов, которые мы будем игнорировать
|
2094 |
ignore_words = set([
|
@@ -3731,5 +3731,4 @@ with gr.Blocks() as demo:
|
|
3731 |
]
|
3732 |
)
|
3733 |
|
3734 |
-
demo.launch()
|
3735 |
-
|
|
|
11 |
from openpyxl.styles import Alignment
|
12 |
import base64
|
13 |
from together import Together
|
14 |
+
import pymorphy3
|
15 |
import pymorphy3
|
16 |
import re
|
17 |
import string
|
|
|
25 |
from mistralai import Mistral
|
26 |
|
27 |
|
28 |
+
#morph = pymorphy3.MorphAnalyzer()
|
29 |
morph = pymorphy3.MorphAnalyzer()
|
30 |
|
31 |
# Установка ключа API для OpenAI, GigaChat и Mistral
|
|
|
464 |
|
465 |
|
466 |
def correct_dash_usage(text):
|
467 |
+
morph = pymorphy3.MorphAnalyzer()
|
468 |
# Step 1: Replace any dash with long dash if surrounded by spaces
|
469 |
text = re.sub(r'\s[-–—]\s', ' — ', text)
|
470 |
|
|
|
526 |
text = re.sub(r'\bею\b', 'ей', text, flags=re.IGNORECASE)
|
527 |
|
528 |
def restore_yo(text):
|
529 |
+
morph = pymorphy3.MorphAnalyzer()
|
530 |
words = text.split()
|
531 |
restored_words = []
|
532 |
|
|
|
1793 |
# 1. Запрещенные слова
|
1794 |
|
1795 |
def check_forbidden_words(message):
|
1796 |
+
morph = pymorphy3.MorphAnalyzer()
|
1797 |
|
1798 |
# Перечень запрещённых слов и фраз
|
1799 |
forbidden_patterns = [
|
|
|
1827 |
# 2 и #3. Обращение к клиенту и приветствие клиента
|
1828 |
|
1829 |
def check_no_greeting(message):
|
1830 |
+
morph = pymorphy3.MorphAnalyzer()
|
1831 |
# Список типичных обращений и приветствий
|
1832 |
greeting_patterns = [
|
1833 |
r"привет\b", r"здравствуй", r"добрый\s(день|вечер|утро)",
|
|
|
1847 |
# 4. Обещания и гарантии
|
1848 |
|
1849 |
def check_no_promises(message):
|
1850 |
+
morph = pymorphy3.MorphAnalyzer()
|
1851 |
promise_patterns = [
|
1852 |
"обещать", "обещание", "гарантировать", "обязаться", "обязать", "обязательство", "обязательный"
|
1853 |
]
|
|
|
1863 |
# 5. Составные конструкции из двух глаголов
|
1864 |
|
1865 |
def check_no_double_verbs(message):
|
1866 |
+
morph = pymorphy3.MorphAnalyzer()
|
1867 |
# Разделяем текст по пробелам и знакам препинания
|
1868 |
words = re.split(r'\s+|[.!?]', message)
|
1869 |
morphs = [morph.parse(word)[0] for word in words]
|
|
|
1881 |
# 6. Причастия и причастные обороты
|
1882 |
|
1883 |
def check_no_participles(message):
|
1884 |
+
morph = pymorphy3.MorphAnalyzer()
|
1885 |
words = message.split()
|
1886 |
morphs = [morph.parse(word)[0] for word in words]
|
1887 |
|
|
|
1893 |
# 7. Деепричастия и деепричастные обороты
|
1894 |
|
1895 |
def check_no_adverbial_participles(message):
|
1896 |
+
morph = pymorphy3.MorphAnalyzer()
|
1897 |
words = message.split()
|
1898 |
morphs = [morph.parse(word)[0] for word in words]
|
1899 |
|
|
|
1905 |
# 8. Превосходная степень прилагательных
|
1906 |
|
1907 |
def check_no_superlative_adjectives(message):
|
1908 |
+
morph = pymorphy3.MorphAnalyzer()
|
1909 |
words = message.split()
|
1910 |
morphs = [morph.parse(word)[0] for word in words]
|
1911 |
|
|
|
1917 |
# 9. Страдательный залог
|
1918 |
|
1919 |
def check_no_passive_voice(message):
|
1920 |
+
morph = pymorphy3.MorphAnalyzer()
|
1921 |
words = message.split()
|
1922 |
morphs = [morph.parse(word)[0] for word in words]
|
1923 |
|
|
|
1929 |
# 10. Порядковые числительные от 10 прописью
|
1930 |
|
1931 |
def check_no_written_out_ordinals(message):
|
1932 |
+
morph = pymorphy3.MorphAnalyzer()
|
1933 |
ordinal_words = [
|
1934 |
"десятый", "одиннадцатый", "двенадцатый", "тринадцатый", "четырнадцатый", "пятнадцатый",
|
1935 |
"шестнадцатый", "семнадцатый", "восемнадцатый", "девятнадцатый", "двадцатый"
|
|
|
2018 |
def check_no_multiple_nouns(message):
|
2019 |
noun_count = 0
|
2020 |
words = re.split(r'\s+|[.!?]', message) # Разбиваем по пробелам и знакам препинания
|
2021 |
+
morph = pymorphy3.MorphAnalyzer()
|
2022 |
|
2023 |
for word in words:
|
2024 |
parsed_word = morph.parse(word)[0]
|
|
|
2088 |
# Доп правило. Повторы слов
|
2089 |
|
2090 |
def check_no_word_repetitions(message):
|
2091 |
+
morph = pymorphy3.MorphAnalyzer()
|
2092 |
|
2093 |
# Список союзов и предлогов, которые мы будем игнорировать
|
2094 |
ignore_words = set([
|
|
|
3731 |
]
|
3732 |
)
|
3733 |
|
3734 |
+
demo.launch()
|
|