Jean commited on
Commit
2376f61
·
verified ·
1 Parent(s): 5ed67ac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -8
app.py CHANGED
@@ -30,19 +30,18 @@ def preprocess_text(text: str) -> str:
30
  processed = " ".join(lemmas)
31
  return processed
32
 
33
- st.title("RuBERT-Tiny Sentiment Classification")
34
 
35
  st.write(
36
  """
37
- This app uses SpaCy for preprocessing (tokenization, stopword removal, lemmatization)
38
- to match the new training process. Then it classifies the sentiment using a fine-tuned
39
- RuBERT-Tiny model.
40
  """
41
  )
42
 
43
- user_input = st.text_area("Enter a Russian text for sentiment classification:")
44
 
45
- if st.button("Predict"):
46
  if user_input.strip():
47
  processed_text = preprocess_text(user_input)
48
 
@@ -53,6 +52,12 @@ if st.button("Predict"):
53
  logits = outputs.logits
54
  prediction = torch.argmax(logits, dim=-1).item()
55
 
56
- st.write(f"Prediction (Sentiment): **{prediction}**")
 
 
 
 
 
 
57
  else:
58
- st.warning("Please enter some text before pressing 'Predict'.")
 
30
  processed = " ".join(lemmas)
31
  return processed
32
 
33
+ st.title("Анализ тональности отзывов с помощью RuBERT-Tiny")
34
 
35
  st.write(
36
  """
37
+ Данный интерфейс позволяет определить тональность отзывов о финансовых организациях с помощью языковой модели RuBERT-Tiny. Приложение производит бинарную классификацию
38
+ текста на "позитивный" и "негативный" классы.
 
39
  """
40
  )
41
 
42
+ user_input = st.text_area("Введите текст отзыва на русском языке:")
43
 
44
+ if st.button("Предсказать"):
45
  if user_input.strip():
46
  processed_text = preprocess_text(user_input)
47
 
 
52
  logits = outputs.logits
53
  prediction = torch.argmax(logits, dim=-1).item()
54
 
55
+ prediction_text = 'None'
56
+ if prediction == 0:
57
+ prediction_text = 'отзыв имеет положительную окраску'
58
+ else:
59
+ prediction_text = 'отзыв имеет негативную окраску'
60
+
61
+ st.write(f"Предсказание: **{prediction_text}**")
62
  else:
63
+ st.warning("Пожалуйста введите какой-либо текст перед нажатием кнопки 'Предсказать'.")