aliicemill commited on
Commit
259076d
·
verified ·
1 Parent(s): 2f0b116

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +542 -0
app.py ADDED
@@ -0,0 +1,542 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import re
3
+ import numpy as np
4
+ import matplotlib.pyplot as plt
5
+ from io import BytesIO
6
+
7
+ def run_turkish():
8
+ # Başlık
9
+ st.title("Note Analyzer Streamlit Uygulaması")
10
+
11
+ # Uygulamanın çalışma prensibi görüntüleme durumu
12
+ if "show_images" not in st.session_state:
13
+ st.session_state.show_images = True # Varsayılan olarak resimler gösterilsin
14
+
15
+ # Kullanıcıdan veri alma (Sidebar sabit kalıyor)
16
+ st.sidebar.header("Girdi Alanları")
17
+
18
+ # Dosya yükleme veya metin girişi seçimi
19
+ input_method = st.sidebar.radio(
20
+ "Notları nasıl gireceksiniz?",
21
+ options=["Dosya Yükle", "Kopyala-Yapıştır"]
22
+ )
23
+
24
+ uploaded_file = None
25
+ text_input = None
26
+
27
+ if input_method == "Dosya Yükle":
28
+ uploaded_file = st.sidebar.file_uploader("Notlar Dosyasını Yükleyin (TXT)", type=["txt"])
29
+ elif input_method == "Kopyala-Yapıştır":
30
+ text_input = st.sidebar.text_area("Notları Yapıştırın", height=200)
31
+
32
+ # Diğer parametreler
33
+ lecture_name = st.sidebar.text_input("Ders Adı", value="Ders Adı")
34
+ perfect_score = st.sidebar.number_input("Sınav Puanı Üst Limiti", value=100, step=1)
35
+ my_note = st.sidebar.number_input("Benim Notum", value=0.0, step=0.1)
36
+ note_s_axis_diff = st.sidebar.number_input("Notlar X Ekseni Ortak Farkı", value=5, step=1)
37
+ amount_s_axis_diff = st.sidebar.number_input("Miktar Y Ekseni Ortak Farkı", value=1, step=1)
38
+ first_step = st.sidebar.number_input("İlk Adım", value=0, step=1)
39
+ increase_amount = st.sidebar.number_input("Artış Miktarı", value=1, step=1)
40
+
41
+ if st.sidebar.button("Analizi Çalıştır"):
42
+ # Butona basıldığında resimleri gizle
43
+ st.session_state.show_images = False
44
+
45
+ # Resimler yalnızca show_images True ise gösterilir
46
+ if st.session_state.show_images:
47
+ st.subheader("Uygulamanın Çalışma Prensibi")
48
+
49
+ # Resimlerin dosya isimlerini sırayla listele
50
+ image_files = ["turkish/a.png", "turkish/b.png", "turkish/c.png", "turkish/d.png"]
51
+
52
+ # Resimleri alt alta ekle
53
+ for image_file in image_files:
54
+ st.image(image_file, use_container_width=True)
55
+
56
+ # Notları yükleme ve işleme işlemleri (Butona basıldıysa çalışır)
57
+ if not st.session_state.show_images:
58
+ if input_method == "Dosya Yükle" and uploaded_file is None:
59
+ st.error("Lütfen bir dosya yükleyin!")
60
+ elif input_method == "Kopyala-Yapıştır" and not text_input:
61
+ st.error("Lütfen notları metin kutusuna yapıştırın!")
62
+ else:
63
+ try:
64
+ # Dosya veya metin kutusundan içerik okuma
65
+ if uploaded_file:
66
+ content = uploaded_file.read().decode("utf-8")
67
+ elif text_input:
68
+ content = text_input
69
+
70
+ # Veriyi işleme
71
+ result = re.split(r'[ \n]+', content)
72
+
73
+ # Strip fonksiyonu ve kaçış dizisi temizliği
74
+ notes_result = [x.strip() for x in result[first_step::increase_amount] if x.strip() != '∅' and x.strip() != "NA"]
75
+ notes_result = list(map(lambda x: float(x), notes_result))
76
+ notes_result = np.array(notes_result)
77
+
78
+ # İstatistikler
79
+ average_x = np.average(notes_result)
80
+ min_x = notes_result.min()
81
+ max_x = notes_result.max()
82
+ std = np.std(notes_result)
83
+ z_score = (my_note - average_x) / std
84
+
85
+ # İstatistikleri ekrana yazdırma
86
+ st.subheader("Genel Bilgiler")
87
+ st.write(f"Katilimci Sayısı: {len(notes_result)}")
88
+ st.write(f"En Düşük Not: {min_x:.2f}")
89
+ st.write(f"En Yüksek Not: {max_x:.2f}")
90
+ st.write(f"Ortalama Not: {average_x:.2f}")
91
+ st.write(f"Standart Sapma: {std:.2f}")
92
+ st.write(f"Z-Skoru: {z_score:.2f}")
93
+
94
+ # Grafik oluşturma
95
+ st.subheader("Not Dağılım Grafiği")
96
+ unique_values, counts = np.unique(notes_result, return_counts=True)
97
+ plt.figure(figsize=(10, 6))
98
+ bars = plt.bar(unique_values, counts, width=0.3)
99
+ plt.axvline(x=average_x, color='red', linestyle='--')
100
+ plt.text(average_x + 1.5, max(counts), 'Ortalama Not', color='red', rotation=0, ha='center', va='bottom')
101
+
102
+ if my_note in unique_values:
103
+ plt.text(my_note, counts[unique_values == my_note][0], 'Benim\nNotum', color='green', rotation=0, ha='center', va='bottom')
104
+
105
+ for bar in bars:
106
+ if bar.get_x() <= my_note < bar.get_x() + bar.get_width():
107
+ bar.set_color('green')
108
+
109
+ plt.title(f'{lecture_name} Not Sayıları Grafiği')
110
+ plt.xlabel('Notlar')
111
+ plt.ylabel('Adet')
112
+ plt.xticks(range(0, int(perfect_score), note_s_axis_diff), rotation=90)
113
+ plt.yticks(range(0, max(counts), amount_s_axis_diff), rotation=0)
114
+
115
+ # Grafik bilgileri
116
+ info_text = (
117
+ f"Katilimci sayısı: {len(notes_result)}\n"
118
+ f"En düşük not: {min_x:.2f}\n"
119
+ f"En yüksek not: {max_x:.2f}\n"
120
+ f"Benim notum: {my_note:.2f}\n"
121
+ f"Ortalama not: {average_x:.2f}\n"
122
+ f"Standart sapma: {std:.2f}\n"
123
+ f"Z-skoru: {z_score:.2f}"
124
+ )
125
+ plt.text(
126
+ 1.05 * max(unique_values), 0.8 * max(counts),
127
+ info_text,
128
+ fontsize=10,
129
+ color="black",
130
+ ha="left",
131
+ va="top",
132
+ bbox=dict(boxstyle="round,pad=0.3", edgecolor="blue", facecolor="lightgrey")
133
+ )
134
+ plt.subplots_adjust(left=0.055, bottom=0.065, right=0.90, top=0.962, wspace=0.2, hspace=0.2)
135
+
136
+ # Sağ alt köşeye "Generated by Note Analyzer" metni ekle
137
+ plt.text(
138
+ 0.99, -0.15, # Sağ alt köşeye konumlandır
139
+ "Generated by Note Analyzer at HuggingFace aliicemill/NoteAnalyzer space",
140
+ fontsize=8,
141
+ color="gray",
142
+ ha="right",
143
+ va="top",
144
+ transform=plt.gca().transAxes # Koordinatları grafiğe göre ayarla
145
+ )
146
+
147
+ # Grafik gösterimi
148
+ st.pyplot(plt)
149
+
150
+ # Grafik indirme bağlantısı
151
+ buf = BytesIO()
152
+ plt.savefig(buf, format="png")
153
+ buf.seek(0)
154
+ st.download_button(
155
+ label="Grafiği İndir",
156
+ data=buf,
157
+ file_name="not_dagilimi.png",
158
+ mime="image/png"
159
+ )
160
+
161
+ except Exception as e:
162
+ st.error(f"Hata: {e}")
163
+
164
+ # Web sayfasının altına isim ve tarih
165
+ st.markdown("---")
166
+ st.write("Developed by: Ali Cemil Özdemir")
167
+ st.write("Date: 01.12.2024")
168
+ st.write("For feedback and suggestions, you can contact me at [email protected]")
169
+
170
+ # Grafiklerin sağ alt köşesine yazı ekleme
171
+ st.markdown("""
172
+ <p style="position:absolute; bottom:0px; right:0px; font-size: 12px; color: gray;">
173
+ Created with Note Analyzer
174
+ </p>
175
+ """, unsafe_allow_html=True)
176
+
177
+
178
+ def run_arabic():
179
+ # العنوان
180
+ st.title("تطبيق محلل الدرجات باستخدام Streamlit")
181
+
182
+ # حالة عرض الصور
183
+ if "show_images" not in st.session_state:
184
+ st.session_state.show_images = True # الافتراضي: يتم عرض الصور
185
+
186
+ # منطقة إدخال البيانات في الشريط الجانبي
187
+ st.sidebar.header("حقول الإدخال")
188
+
189
+ # اختيار رفع ملف أو إدخال النصوص يدويًا
190
+ input_method = st.sidebar.radio(
191
+ "كيف ستقدم الدرجات؟",
192
+ options=["رفع ملف", "نسخ ولصق"]
193
+ )
194
+
195
+ uploaded_file = None
196
+ text_input = None
197
+
198
+ if input_method == "رفع ملف":
199
+ uploaded_file = st.sidebar.file_uploader("قم برفع ملف الدرجات (TXT)", type=["txt"])
200
+ elif input_method == "نسخ ولصق":
201
+ text_input = st.sidebar.text_area("قم بلصق الدرجات هنا", height=200)
202
+
203
+ # المعلمات الأخرى
204
+ lecture_name = st.sidebar.text_input("اسم المادة", value="اسم المادة")
205
+ perfect_score = st.sidebar.number_input("الدرجة الكاملة", value=100, step=1)
206
+ my_note = st.sidebar.number_input("درجتي", value=0.0, step=0.1)
207
+ note_s_axis_diff = st.sidebar.number_input("حجم خطوات المحور السيني للدرجات", value=5, step=1)
208
+ amount_s_axis_diff = st.sidebar.number_input("حجم خطوات المحور الصادي للتكرار", value=1, step=1)
209
+ first_step = st.sidebar.number_input("الخطوة الأولى", value=0, step=1)
210
+ increase_amount = st.sidebar.number_input("مقدار الزيادة", value=1, step=1)
211
+
212
+ if st.sidebar.button("تشغيل التحليل"):
213
+ # إخفاء الصور عند النقر على الزر
214
+ st.session_state.show_images = False
215
+
216
+ # عرض الصور فقط إذا كانت show_images صحيحة
217
+ if st.session_state.show_images:
218
+ st.subheader("كيفية عمل التطبيق")
219
+
220
+ # قائمة بأسماء ملفات الصور بالترتيب
221
+ image_files = ["arabic/a.png", "arabic/b.png", "arabic/c.png", "arabic/d.png"]
222
+
223
+ # عرض الصور واحدة تحت الأخرى
224
+ for image_file in image_files:
225
+ st.image(image_file, use_container_width=True)
226
+
227
+ # تحميل ومعالجة الدرجات (يعمل فقط إذا تم النقر على الزر)
228
+ if not st.session_state.show_images:
229
+ if input_method == "رفع ملف" and uploaded_file is None:
230
+ st.error("يرجى رفع ملف!")
231
+ elif input_method == "نسخ ولصق" and not text_input:
232
+ st.error("يرجى لصق الدرجات في مربع النص!")
233
+ else:
234
+ try:
235
+ # قراءة المحتوى من الملف أو مربع النص
236
+ if uploaded_file:
237
+ content = uploaded_file.read().decode("utf-8")
238
+ elif text_input:
239
+ content = text_input
240
+
241
+ # معالجة البيانات
242
+ result = re.split(r'[ \n]+', content)
243
+
244
+ # تنظيف وتصنيف البيانات
245
+ notes_result = [x.strip() for x in result[first_step::increase_amount] if x.strip() != '∅' and x.strip() != "NA"]
246
+ notes_result = list(map(lambda x: float(x), notes_result))
247
+ notes_result = np.array(notes_result)
248
+
249
+ # الإحصائيات
250
+ average_x = np.average(notes_result)
251
+ min_x = notes_result.min()
252
+ max_x = notes_result.max()
253
+ std = np.std(notes_result)
254
+ z_score = (my_note - average_x) / std
255
+
256
+ # عرض الإحصائيات
257
+ st.subheader("المعلومات العامة")
258
+ st.write(f"عدد المشاركين: {len(notes_result)}")
259
+ st.write(f"أقل درجة: {min_x:.2f}")
260
+ st.write(f"أعلى درجة: {max_x:.2f}")
261
+ st.write(f"متوسط الدرجات: {average_x:.2f}")
262
+ st.write(f"الانحراف المعياري: {std:.2f}")
263
+ st.write(f"درجة Z: {z_score:.2f}")
264
+
265
+ # إنشاء الرسم البياني
266
+ st.subheader("رسم توزيع الدرجات")
267
+ unique_values, counts = np.unique(notes_result, return_counts=True)
268
+ plt.figure(figsize=(10, 6))
269
+ bars = plt.bar(unique_values, counts, width=0.3)
270
+ plt.axvline(x=average_x, color='red', linestyle='--')
271
+ plt.text(average_x + 1.5, max(counts), 'متوسط الدرجات', color='red', rotation=0, ha='center', va='bottom')
272
+
273
+ if my_note in unique_values:
274
+ plt.text(my_note, counts[unique_values == my_note][0], 'درجتي', color='green', rotation=0, ha='center', va='bottom')
275
+
276
+ for bar in bars:
277
+ if bar.get_x() <= my_note < bar.get_x() + bar.get_width():
278
+ bar.set_color('green')
279
+
280
+ plt.title(f'رسم توزيع الدرجات لمادة {lecture_name}')
281
+ plt.xlabel('الدرجات')
282
+ plt.ylabel('التكرار')
283
+ plt.xticks(range(0, int(perfect_score), note_s_axis_diff), rotation=90)
284
+ plt.yticks(range(0, max(counts), amount_s_axis_diff), rotation=0)
285
+
286
+ # إضافة معلومات إلى الرسم البياني
287
+ info_text = (
288
+ f"عدد المشاركين: {len(notes_result)}\n"
289
+ f"أقل درجة: {min_x:.2f}\n"
290
+ f"أعلى درجة: {max_x:.2f}\n"
291
+ f"درجتي: {my_note:.2f}\n"
292
+ f"متوسط الدرجات: {average_x:.2f}\n"
293
+ f"الانحراف المعياري: {std:.2f}\n"
294
+ f"درجة Z: {z_score:.2f}"
295
+ )
296
+ plt.text(
297
+ 1.05 * max(unique_values), 0.8 * max(counts),
298
+ info_text,
299
+ fontsize=10,
300
+ color="black",
301
+ ha="left",
302
+ va="top",
303
+ bbox=dict(boxstyle="round,pad=0.3", edgecolor="blue", facecolor="lightgrey")
304
+ )
305
+ plt.subplots_adjust(left=0.055, bottom=0.065, right=0.90, top=0.962, wspace=0.2, hspace=0.2)
306
+ # Sağ alt köşeye "Generated by Note Analyzer" metni ekle
307
+ plt.text(
308
+ 0.99, -0.15, # Sağ alt köşeye konumlandır
309
+ "Generated by Note Analyzer at HuggingFace aliicemill/NoteAnalyzer space",
310
+ fontsize=8,
311
+ color="gray",
312
+ ha="right",
313
+ va="top",
314
+ transform=plt.gca().transAxes # Koordinatları grafiğe göre ayarla
315
+ )
316
+ # عرض الرسم البياني
317
+ st.pyplot(plt)
318
+
319
+ # زر لتحميل الرسم البياني
320
+ buf = BytesIO()
321
+ plt.savefig(buf, format="png")
322
+ buf.seek(0)
323
+ st.download_button(
324
+ label="تحميل الرسم البياني",
325
+ data=buf,
326
+ file_name="score_distribution.png",
327
+ mime="image/png"
328
+ )
329
+
330
+ except Exception as e:
331
+ st.error(f"خطأ: {e}")
332
+
333
+ # التذييل
334
+ st.markdown("---")
335
+ st.write("تم التطوير بواسطة: علي جميل أوزدمير")
336
+ st.write("التاريخ: 01.12.2024")
337
+ st.write("للتعليقات والاقتراحات، يمكنك التواصل عبر: [email protected]")
338
+
339
+ # إضافة ملاحظة أسفل الزاوية اليمنى
340
+ st.markdown("""
341
+ <p style="position:absolute; bottom:0px; right:0px; font-size: 12px; color: gray;">
342
+ تم الإنشاء باستخدام محلل الدرجات
343
+ </p>
344
+ """, unsafe_allow_html=True)
345
+
346
+
347
+ def run_english():
348
+ # Title
349
+ st.title("Note Analyzer Streamlit Application")
350
+
351
+ # Image display state
352
+ if "show_images" not in st.session_state:
353
+ st.session_state.show_images = True # Default: images are shown
354
+
355
+ # Sidebar input area
356
+ st.sidebar.header("Input Fields")
357
+
358
+ # File upload or text input selection
359
+ input_method = st.sidebar.radio(
360
+ "How will you provide the notes?",
361
+ options=["Upload File", "Copy-Paste"]
362
+ )
363
+
364
+ uploaded_file = None
365
+ text_input = None
366
+
367
+ if input_method == "Upload File":
368
+ uploaded_file = st.sidebar.file_uploader("Upload the Notes File (TXT)", type=["txt"])
369
+ elif input_method == "Copy-Paste":
370
+ text_input = st.sidebar.text_area("Paste the Notes Here", height=200)
371
+
372
+ # Other parameters
373
+ lecture_name = st.sidebar.text_input("Course Name", value="Course Name")
374
+ perfect_score = st.sidebar.number_input("Maximum Exam Score", value=100, step=1)
375
+ my_note = st.sidebar.number_input("My Score", value=0.0, step=0.1)
376
+ note_s_axis_diff = st.sidebar.number_input("Score X-Axis Step Size", value=5, step=1)
377
+ amount_s_axis_diff = st.sidebar.number_input("Frequency Y-Axis Step Size", value=1, step=1)
378
+ first_step = st.sidebar.number_input("First Step", value=0, step=1)
379
+ increase_amount = st.sidebar.number_input("Step Increase", value=1, step=1)
380
+
381
+ if st.sidebar.button("Run Analysis"):
382
+ # Hide images when the button is clicked
383
+ st.session_state.show_images = False
384
+
385
+ # Show images only if show_images is True
386
+ if st.session_state.show_images:
387
+ st.subheader("How the Application Works")
388
+
389
+ # List the image filenames in order
390
+ image_files = ["english/a.png", "english/b.png", "english/c.png", "english/d.png"]
391
+
392
+ # Display images one below the other
393
+ for image_file in image_files:
394
+ st.image(image_file, use_container_width=True)
395
+
396
+ # Load and process notes (Only works if the button is clicked)
397
+ if not st.session_state.show_images:
398
+ if input_method == "Upload File" and uploaded_file is None:
399
+ st.error("Please upload a file!")
400
+ elif input_method == "Copy-Paste" and not text_input:
401
+ st.error("Please paste the notes into the text area!")
402
+ else:
403
+ try:
404
+ # Read content from file or text area
405
+ if uploaded_file:
406
+ content = uploaded_file.read().decode("utf-8")
407
+ elif text_input:
408
+ content = text_input
409
+
410
+ # Process the data
411
+ result = re.split(r'[ \n]+', content)
412
+
413
+ # Clean and filter the data
414
+ notes_result = [x.strip() for x in result[first_step::increase_amount] if x.strip() != '∅' and x.strip() != "NA"]
415
+ notes_result = list(map(lambda x: float(x), notes_result))
416
+ notes_result = np.array(notes_result)
417
+
418
+ # Statistics
419
+ average_x = np.average(notes_result)
420
+ min_x = notes_result.min()
421
+ max_x = notes_result.max()
422
+ std = np.std(notes_result)
423
+ z_score = (my_note - average_x) / std
424
+
425
+ # Display statistics
426
+ st.subheader("General Information")
427
+ st.write(f"Number of Participants: {len(notes_result)}")
428
+ st.write(f"Lowest Score: {min_x:.2f}")
429
+ st.write(f"Highest Score: {max_x:.2f}")
430
+ st.write(f"Average Score: {average_x:.2f}")
431
+ st.write(f"Standard Deviation: {std:.2f}")
432
+ st.write(f"Z-Score: {z_score:.2f}")
433
+
434
+ # Create plot
435
+ st.subheader("Score Distribution Graph")
436
+ unique_values, counts = np.unique(notes_result, return_counts=True)
437
+ plt.figure(figsize=(10, 6))
438
+ bars = plt.bar(unique_values, counts, width=0.3)
439
+ plt.axvline(x=average_x, color='red', linestyle='--')
440
+ plt.text(average_x + 1.5, max(counts), 'Average Score', color='red', rotation=0, ha='center', va='bottom')
441
+
442
+ if my_note in unique_values:
443
+ plt.text(my_note, counts[unique_values == my_note][0], 'My\nScore', color='green', rotation=0, ha='center', va='bottom')
444
+
445
+ for bar in bars:
446
+ if bar.get_x() <= my_note < bar.get_x() + bar.get_width():
447
+ bar.set_color('green')
448
+
449
+ plt.title(f'{lecture_name} Score Distribution')
450
+ plt.xlabel('Scores')
451
+ plt.ylabel('Count')
452
+ plt.xticks(range(0, int(perfect_score), note_s_axis_diff), rotation=90)
453
+ plt.yticks(range(0, max(counts), amount_s_axis_diff), rotation=0)
454
+
455
+ # Add graph information
456
+ info_text = (
457
+ f"Number of participants: {len(notes_result)}\n"
458
+ f"Lowest score: {min_x:.2f}\n"
459
+ f"Highest score: {max_x:.2f}\n"
460
+ f"My score: {my_note:.2f}\n"
461
+ f"Average score: {average_x:.2f}\n"
462
+ f"Standard deviation: {std:.2f}\n"
463
+ f"Z-score: {z_score:.2f}"
464
+ )
465
+ plt.text(
466
+ 1.05 * max(unique_values), 0.8 * max(counts),
467
+ info_text,
468
+ fontsize=10,
469
+ color="black",
470
+ ha="left",
471
+ va="top",
472
+ bbox=dict(boxstyle="round,pad=0.3", edgecolor="blue", facecolor="lightgrey")
473
+ )
474
+ plt.subplots_adjust(left=0.055, bottom=0.065, right=0.90, top=0.962, wspace=0.2, hspace=0.2)
475
+ # Sağ alt köşeye "Generated by Note Analyzer" metni ekle
476
+ plt.text(
477
+ 0.99, -0.15, # Sağ alt köşeye konumlandır
478
+ "Generated by Note Analyzer at HuggingFace aliicemill/NoteAnalyzer space",
479
+ fontsize=8,
480
+ color="gray",
481
+ ha="right",
482
+ va="top",
483
+ transform=plt.gca().transAxes # Koordinatları grafiğe göre ayarla
484
+ )
485
+
486
+ # Display the plot
487
+ st.pyplot(plt)
488
+
489
+ # Download button for the plot
490
+ buf = BytesIO()
491
+ plt.savefig(buf, format="png")
492
+ buf.seek(0)
493
+ st.download_button(
494
+ label="Download Graph",
495
+ data=buf,
496
+ file_name="score_distribution.png",
497
+ mime="image/png"
498
+ )
499
+
500
+ except Exception as e:
501
+ st.error(f"Error: {e}")
502
+
503
+ # Footer
504
+ st.markdown("---")
505
+ st.write("Developed by: Ali Cemil Özdemir")
506
+ st.write("Date: 01.12.2024")
507
+ st.write("For feedback and suggestions, you can contact me at [email protected]")
508
+
509
+ # Add a note at the bottom right corner of the page
510
+ st.markdown("""
511
+ <p style="position:absolute; bottom:0px; right:0px; font-size: 12px; color: gray;">
512
+ Created with Note Analyzer
513
+ </p>
514
+ """, unsafe_allow_html=True)
515
+
516
+ # Session State'i başlat
517
+ if "language" not in st.session_state:
518
+ st.session_state.language = None
519
+
520
+ # Dil seçimi ekranı
521
+ if st.session_state.language is None:
522
+ st.title("Select language / Dili seçin / اختر اللغة")
523
+ col1, col2, col3 = st.columns(3)
524
+
525
+ with col1:
526
+ if st.button("Türkçe"):
527
+ st.session_state.language = "turkish"
528
+ with col2:
529
+ if st.button("English"):
530
+ st.session_state.language = "english"
531
+ with col3:
532
+ if st.button("عربي"):
533
+ st.session_state.language = "arabic"
534
+
535
+ # Seçilen dilin programını çalıştır
536
+ else:
537
+ if st.session_state.language == "turkish":
538
+ run_turkish()
539
+ elif st.session_state.language == "english":
540
+ run_english()
541
+ elif st.session_state.language == "arabic":
542
+ run_arabic()