Yerzhxn commited on
Commit
a998357
·
verified ·
1 Parent(s): c5d8201

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -64,18 +64,23 @@ def preprocess_text(text):
64
  return ' '.join(lemmas)
65
 
66
 
67
- # Updated model paths
 
 
 
 
68
  def find_best_matches(profession, nkz_list, vectorizer, tfidf_nkz, top_n=10):
69
  """Находит топ-10 наилучших соответствий для одной профессии в списке НКЗ."""
70
  # Предобработка профессии
71
  processed_profession = preprocess_text(profession)
72
-
 
73
  # Преобразование векторной модели
74
  tfidf_profession = vectorizer.transform([processed_profession])
75
-
76
  # Вычисление схожести
77
  similarity = cosine_similarity(tfidf_profession, tfidf_nkz)
78
-
79
  # Получаем индексы топ-N самых схожих профессий
80
  top_n_idx = similarity[0].argsort()[-top_n:][::-1] # Сортируем по убыванию
81
 
@@ -83,15 +88,13 @@ def find_best_matches(profession, nkz_list, vectorizer, tfidf_nkz, top_n=10):
83
  top_matches = []
84
  for idx in top_n_idx:
85
  top_matches.append({
86
- 'profession': profession,
87
  'nkz_match': nkz_list.iloc[idx]['NAME_RU2'],
88
  'nkz_code': nkz_list.iloc[idx]['CODE'], # Код НКЗ
89
  'similarity': similarity[0][idx]
90
  })
91
  dfs = pd.DataFrame(top_matches)
92
- return dfs
93
-
94
-
95
 
96
 
97
 
 
64
  return ' '.join(lemmas)
65
 
66
 
67
+ def text_correct(text):
68
+ matches = tool.check(text)
69
+ text = language_tool_python.utils.correct(text, matches)
70
+ return text
71
+
72
  def find_best_matches(profession, nkz_list, vectorizer, tfidf_nkz, top_n=10):
73
  """Находит топ-10 наилучших соответствий для одной профессии в списке НКЗ."""
74
  # Предобработка профессии
75
  processed_profession = preprocess_text(profession)
76
+ processed_profession = text_correct(processed_profession)
77
+ print(processed_profession)
78
  # Преобразование векторной модели
79
  tfidf_profession = vectorizer.transform([processed_profession])
80
+
81
  # Вычисление схожести
82
  similarity = cosine_similarity(tfidf_profession, tfidf_nkz)
83
+
84
  # Получаем индексы топ-N самых схожих профессий
85
  top_n_idx = similarity[0].argsort()[-top_n:][::-1] # Сортируем по убыванию
86
 
 
88
  top_matches = []
89
  for idx in top_n_idx:
90
  top_matches.append({
91
+ 'profession': processed_profession,
92
  'nkz_match': nkz_list.iloc[idx]['NAME_RU2'],
93
  'nkz_code': nkz_list.iloc[idx]['CODE'], # Код НКЗ
94
  'similarity': similarity[0][idx]
95
  })
96
  dfs = pd.DataFrame(top_matches)
97
+ return dfs
 
 
98
 
99
 
100