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