ESMATUGBA commited on
Commit
ab6da37
·
verified ·
1 Parent(s): 9677bb6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -13
app.py CHANGED
@@ -98,42 +98,38 @@ all_examples = {
98
  selected_cat = st.sidebar.selectbox("Select Category / Kategori Seçin:", [""] + list(all_examples.keys()))
99
 
100
  if selected_cat != "":
101
- st.sidebar.markdown(f"### {selected_cat} Örnekleri:")
102
- st.sidebar.write("Kopyalamak için üzerine tıklayın:")
 
103
  for i, ex in enumerate(all_examples[selected_cat], 1):
104
- st.sidebar.info(f"Örnek {i}:")
105
  st.sidebar.code(ex, language=None)
106
 
107
- # --- ANA SAYFA (BAŞLIKLAR GÜNCELLENDİ) ---
108
  st.title("📰 Multidisciplinary News Classifier / Çok Disiplinli Haber Sınıflandırıcı")
109
  st.markdown("---")
110
 
111
- user_input = st.text_area("News Headline / Haber Başlığı:", height=150, placeholder="Sol taraftan bir örnek kopyalayıp buraya yapıştırın...")
112
 
113
  if st.button("Predict / Tahmin Et"):
114
  if user_input.strip() != "":
115
  with st.spinner('Analiz ediliyor / Processing...'):
116
- # 1. Tahmin
117
  category, confidence, all_probs = predict_news(user_input)
118
 
119
- # 2. Çeviri
120
  try:
121
  translated = str(TextBlob(user_input).translate(from_lang='en', to='tr'))
122
  except:
123
- translated = "Çeviri şu an yapılamıyor."
124
 
125
  st.balloons()
126
 
127
- # 3. Haber ve Çeviri Gösterimi
128
- st.info(f"**Original / Orijinal:** {user_input}\n\n**Türkçe Çeviri / Turkish Translation:** *{translated}*")
129
  st.markdown("---")
130
 
131
- # 4. Sonuçlar (Başlıklar Türkçe-İngilizce yapıldı)
132
  res_col1, res_col2 = st.columns(2)
133
  res_col1.success(f"**Predicted Category / Tahmin Edilen Kategori:**\n### {category}")
134
  res_col2.warning(f"**Confidence Score / Güven Oranı:**\n### %{confidence*100:.2f}")
135
 
136
- # 5. Mavi Grafik
137
  labels = le.classes_
138
  fig = go.Figure(go.Bar(
139
  x=all_probs, y=labels, orientation='h',
@@ -143,4 +139,4 @@ if st.button("Predict / Tahmin Et"):
143
  fig.update_layout(title="Probability Graph / Olasılık Grafiği", height=350)
144
  st.plotly_chart(fig, use_container_width=True)
145
  else:
146
- st.warning("⚠️ Lütfen bir haber başlığı girin! / Please enter a headline!")
 
98
  selected_cat = st.sidebar.selectbox("Select Category / Kategori Seçin:", [""] + list(all_examples.keys()))
99
 
100
  if selected_cat != "":
101
+ st.sidebar.markdown(f"### {selected_cat} Samples / Örnekleri:")
102
+ # İSTEDİĞİN DÜZELTME BURADA:
103
+ st.sidebar.write("Click to copy / Kopyalamak üzere tıklayın:")
104
  for i, ex in enumerate(all_examples[selected_cat], 1):
105
+ st.sidebar.info(f"Example / Örnek {i}:")
106
  st.sidebar.code(ex, language=None)
107
 
108
+ # --- ANA SAYFA ---
109
  st.title("📰 Multidisciplinary News Classifier / Çok Disiplinli Haber Sınıflandırıcı")
110
  st.markdown("---")
111
 
112
+ user_input = st.text_area("News Headline / Haber Başlığı:", height=150, placeholder="Copy an example from the left and paste it here... / Sol taraftan bir örnek kopyalayıp buraya yapıştırın...")
113
 
114
  if st.button("Predict / Tahmin Et"):
115
  if user_input.strip() != "":
116
  with st.spinner('Analiz ediliyor / Processing...'):
 
117
  category, confidence, all_probs = predict_news(user_input)
118
 
 
119
  try:
120
  translated = str(TextBlob(user_input).translate(from_lang='en', to='tr'))
121
  except:
122
+ translated = "Çeviri şu an yapılamıyor / Translation failed."
123
 
124
  st.balloons()
125
 
126
+ st.info(f"**Original / Orijinal:** {user_input}\n\n**Turkish Translation / Türkçe Çeviri:** *{translated}*")
 
127
  st.markdown("---")
128
 
 
129
  res_col1, res_col2 = st.columns(2)
130
  res_col1.success(f"**Predicted Category / Tahmin Edilen Kategori:**\n### {category}")
131
  res_col2.warning(f"**Confidence Score / Güven Oranı:**\n### %{confidence*100:.2f}")
132
 
 
133
  labels = le.classes_
134
  fig = go.Figure(go.Bar(
135
  x=all_probs, y=labels, orientation='h',
 
139
  fig.update_layout(title="Probability Graph / Olasılık Grafiği", height=350)
140
  st.plotly_chart(fig, use_container_width=True)
141
  else:
142
+ st.warning("⚠️ Please enter a headline! / Lütfen bir haber başlığı girin!")