aliicemill commited on
Commit
70bcdd3
·
verified ·
1 Parent(s): b054803

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +91 -23
app.py CHANGED
@@ -3,13 +3,81 @@ import numpy as np
3
  import matplotlib.pyplot as plt
4
  from io import BytesIO
5
  import streamlit as st
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
  # Başlık
8
- st.title("Note Analyzer Streamlit Uygulaması")
 
 
 
 
 
 
 
 
9
 
10
  # Kullanıcıdan veri alma (Sidebar sabit kalıyor)
11
  st.sidebar.header("Girdi Alanları")
 
 
12
  input_method = st.sidebar.radio("Notları nasıl gireceksiniz?", options=["Dosya Yükle", "Kopyala-Yapıştır"])
 
13
  uploaded_file = None
14
  text_input = None
15
 
@@ -18,6 +86,7 @@ if input_method == "Dosya Yükle":
18
  elif input_method == "Kopyala-Yapıştır":
19
  text_input = st.sidebar.text_area("Notları Yapıştırın", height=200)
20
 
 
21
  lecture_name = st.sidebar.text_input("Ders Adı", value="Ders Adı")
22
  perfect_score = st.sidebar.number_input("Sınav Puanı Üst Limiti", value=100, step=1)
23
  my_note = st.sidebar.number_input("Benim Notum", value=0.0, step=0.1)
@@ -28,9 +97,9 @@ increase_amount = st.sidebar.number_input("Artış Miktarı", value=1, step=1)
28
 
29
  if st.sidebar.button("Analizi Çalıştır"):
30
  if input_method == "Dosya Yükle" and uploaded_file is None:
31
- st.error("Lütfen bir dosya yükleyin!")
32
  elif input_method == "Kopyala-Yapıştır" and not text_input:
33
- st.error("Lütfen notları metin kutusuna yapıştırın!")
34
  else:
35
  try:
36
  if uploaded_file:
@@ -52,13 +121,13 @@ if st.sidebar.button("Analizi Çalıştır"):
52
  std = np.std(notes_result)
53
  z_score = (my_note - average_x) / std
54
 
55
- st.subheader("Genel Bilgiler")
56
- st.write(f"Katilimci Sayısı: {len(notes_result)}")
57
- st.write(f"En Düşük Not: {min_x:.2f}")
58
- st.write(f"En Yüksek Not: {max_x:.2f}")
59
- st.write(f"Ortalama Not: {average_x:.2f}")
60
- st.write(f"Standart Sapma: {std:.2f}")
61
- st.write(f"Z-Skoru: {z_score:.2f}")
62
 
63
  # Grafik oluşturma
64
  unique_values, counts = np.unique(notes_result, return_counts=True)
@@ -66,29 +135,28 @@ if st.sidebar.button("Analizi Çalıştır"):
66
 
67
  bars = ax.bar(unique_values, counts, width=0.3)
68
  ax.axvline(x=average_x, color='red', linestyle='--')
69
- ax.text(average_x + 1.5, max(counts), 'Ortalama Not', color='red', rotation=0, ha='center', va='bottom')
70
 
71
  if my_note in unique_values:
72
- ax.text(my_note, counts[unique_values == my_note][0], 'Benim\nNotum', color='green', rotation=0, ha='center', va='bottom')
73
 
74
  for bar in bars:
75
  if bar.get_x() <= my_note < bar.get_x() + bar.get_width():
76
  bar.set_color('green')
77
 
78
- ax.set_title(f'{lecture_name} Not Sayıları Grafiği')
79
- ax.set_xlabel('Notlar')
80
- ax.set_ylabel('Adet')
81
  ax.set_xticks(range(0, int(perfect_score), note_s_axis_diff))
82
  ax.set_yticks(range(0, max(counts), amount_s_axis_diff))
83
 
84
  info_text = (
85
- f"Katilimci sayısı: {len(notes_result)}\n"
86
- f"En düşük not: {min_x:.2f}\n"
87
- f"En yüksek not: {max_x:.2f}\n"
88
- f"Benim notum: {my_note:.2f}\n"
89
- f"Ortalama not: {average_x:.2f}\n"
90
- f"Standart sapma: {std:.2f}\n"
91
- f"Z-skoru: {z_score:.2f}"
92
  )
93
  ax.text(
94
  1.05 * max(unique_values), 0.8 * max(counts),
@@ -106,7 +174,7 @@ if st.sidebar.button("Analizi Çalıştır"):
106
  buf.seek(0)
107
 
108
  st.download_button(
109
- label="Grafiği İndir",
110
  data=buf,
111
  file_name="not_dagilimi.png",
112
  mime="image/png"
 
3
  import matplotlib.pyplot as plt
4
  from io import BytesIO
5
  import streamlit as st
6
+ import os
7
+
8
+ # Dil Seçimi
9
+ language = st.selectbox("Select Language / اختر اللغة / Seçiniz", ["Türkçe", "English", "عربي"])
10
+
11
+ # Dil Desteği İçin Metinler
12
+ if language == "Türkçe":
13
+ title_text = "Not Analyzer Streamlit Uygulaması"
14
+ subheader_text = "Uygulamanın Çalışma Prensibi"
15
+ error_message = "Lütfen bir dosya yükleyin!" if input_method == "Dosya Yükle" else "Lütfen notları metin kutusuna yapıştırın!"
16
+ participant_text = "Katilimci Sayısı"
17
+ min_text = "En Düşük Not"
18
+ max_text = "En Yüksek Not"
19
+ avg_text = "Ortalama Not"
20
+ std_dev_text = "Standart Sapma"
21
+ z_score_text = "Z-Skoru"
22
+ download_text = "Grafiği İndir"
23
+ info_text_header = "Genel Bilgiler"
24
+ chart_title = "{lecture_name} Not Sayıları Grafiği"
25
+ xlabel = "Notlar"
26
+ ylabel = "Adet"
27
+
28
+ elif language == "English":
29
+ title_text = "Note Analyzer Streamlit Application"
30
+ subheader_text = "How the Application Works"
31
+ error_message = "Please upload a file!" if input_method == "Upload File" else "Please paste the notes in the text box!"
32
+ participant_text = "Number of Participants"
33
+ min_text = "Lowest Grade"
34
+ max_text = "Highest Grade"
35
+ avg_text = "Average Grade"
36
+ std_dev_text = "Standard Deviation"
37
+ z_score_text = "Z-Score"
38
+ download_text = "Download Graph"
39
+ info_text_header = "General Information"
40
+ chart_title = "{lecture_name} Grade Distribution Graph"
41
+ xlabel = "Grades"
42
+ ylabel = "Count"
43
+
44
+ else: # Arabic
45
+ title_text = "تطبيق تحليل الدرجات"
46
+ subheader_text = "مبدأ عمل التطبيق"
47
+ error_message = "من فضلك حمّل ملفًا!" if input_method == "تحميل الملف" else "من فضلك الصق الملاحظات في مربع النص!"
48
+ participant_text = "عدد المشاركين"
49
+ min_text = "أدنى درجة"
50
+ max_text = "أعلى درجة"
51
+ avg_text = "متوسط الدرجة"
52
+ std_dev_text = "الانحراف المعياري"
53
+ z_score_text = "الدرجة Z"
54
+ download_text = "تنزيل الرسم البياني"
55
+ info_text_header = "المعلومات العامة"
56
+ chart_title = "{lecture_name} الرسم البياني لتوزيع الدرجات"
57
+ xlabel = "الدرجات"
58
+ ylabel = "العدد"
59
+
60
+ # Resim Dosya Yolları
61
+ image_folder = language.lower() # dilin ismini küçük harf ile alıyoruz (örn: "english", "arabic", "turkish")
62
+ image_files = [f"{image_folder}/{ch}.png" for ch in ['a', 'b', 'c', 'd', 'e', 'f', 'g']]
63
 
64
  # Başlık
65
+ st.title(title_text)
66
+
67
+ # Açıklama Resimleri
68
+ st.subheader(subheader_text)
69
+
70
+ # Resimleri alt alta ekle
71
+ for image_file in image_files:
72
+ if os.path.exists(image_file):
73
+ st.image(image_file, use_container_width=True) # Yeni parametre kullanıldı
74
 
75
  # Kullanıcıdan veri alma (Sidebar sabit kalıyor)
76
  st.sidebar.header("Girdi Alanları")
77
+
78
+ # Dosya yükleme veya metin girişi seçimi
79
  input_method = st.sidebar.radio("Notları nasıl gireceksiniz?", options=["Dosya Yükle", "Kopyala-Yapıştır"])
80
+
81
  uploaded_file = None
82
  text_input = None
83
 
 
86
  elif input_method == "Kopyala-Yapıştır":
87
  text_input = st.sidebar.text_area("Notları Yapıştırın", height=200)
88
 
89
+ # Diğer parametreler
90
  lecture_name = st.sidebar.text_input("Ders Adı", value="Ders Adı")
91
  perfect_score = st.sidebar.number_input("Sınav Puanı Üst Limiti", value=100, step=1)
92
  my_note = st.sidebar.number_input("Benim Notum", value=0.0, step=0.1)
 
97
 
98
  if st.sidebar.button("Analizi Çalıştır"):
99
  if input_method == "Dosya Yükle" and uploaded_file is None:
100
+ st.error(error_message)
101
  elif input_method == "Kopyala-Yapıştır" and not text_input:
102
+ st.error(error_message)
103
  else:
104
  try:
105
  if uploaded_file:
 
121
  std = np.std(notes_result)
122
  z_score = (my_note - average_x) / std
123
 
124
+ st.subheader(info_text_header)
125
+ st.write(f"{participant_text}: {len(notes_result)}")
126
+ st.write(f"{min_text}: {min_x:.2f}")
127
+ st.write(f"{max_text}: {max_x:.2f}")
128
+ st.write(f"{avg_text}: {average_x:.2f}")
129
+ st.write(f"{std_dev_text}: {std:.2f}")
130
+ st.write(f"{z_score_text}: {z_score:.2f}")
131
 
132
  # Grafik oluşturma
133
  unique_values, counts = np.unique(notes_result, return_counts=True)
 
135
 
136
  bars = ax.bar(unique_values, counts, width=0.3)
137
  ax.axvline(x=average_x, color='red', linestyle='--')
138
+ ax.text(average_x + 1.5, max(counts), f'{avg_text} ', color='red', rotation=0, ha='center', va='bottom')
139
 
140
  if my_note in unique_values:
141
+ ax.text(my_note, counts[unique_values == my_note][0], f'{my_note}\n{z_score_text}', color='green', rotation=0, ha='center', va='bottom')
142
 
143
  for bar in bars:
144
  if bar.get_x() <= my_note < bar.get_x() + bar.get_width():
145
  bar.set_color('green')
146
 
147
+ ax.set_title(f'{lecture_name} {chart_title}')
148
+ ax.set_xlabel(xlabel)
149
+ ax.set_ylabel(ylabel)
150
  ax.set_xticks(range(0, int(perfect_score), note_s_axis_diff))
151
  ax.set_yticks(range(0, max(counts), amount_s_axis_diff))
152
 
153
  info_text = (
154
+ f"{participant_text}: {len(notes_result)}\n"
155
+ f"{min_text}: {min_x:.2f}\n"
156
+ f"{max_text}: {max_x:.2f}\n"
157
+ f"{my_note} {avg_text}: {average_x:.2f}\n"
158
+ f"{std_dev_text}: {std:.2f}\n"
159
+ f"{z_score_text}: {z_score:.2f}"
 
160
  )
161
  ax.text(
162
  1.05 * max(unique_values), 0.8 * max(counts),
 
174
  buf.seek(0)
175
 
176
  st.download_button(
177
+ label=download_text,
178
  data=buf,
179
  file_name="not_dagilimi.png",
180
  mime="image/png"