Spaces:
Sleeping
Sleeping
Upload 4 files
Browse files
app.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
# Dil seçimini kaydetmek için session_state kullanımı
|
| 4 |
+
if "language" not in st.session_state:
|
| 5 |
+
st.session_state.language = None # Başlangıçta dil seçimi yapılmamış
|
| 6 |
+
|
| 7 |
+
# Eğer dil seçilmemişse, kullanıcıdan dil seçimi istenir
|
| 8 |
+
if st.session_state.language is None:
|
| 9 |
+
st.title("Select language / Dili seçin / اختر اللغة")
|
| 10 |
+
|
| 11 |
+
col1, col2, col3 = st.columns(3)
|
| 12 |
+
|
| 13 |
+
with col1:
|
| 14 |
+
if st.button("Türkçe"):
|
| 15 |
+
st.session_state.language = "turkish"
|
| 16 |
+
with col2:
|
| 17 |
+
if st.button("English"):
|
| 18 |
+
st.session_state.language = "english"
|
| 19 |
+
with col3:
|
| 20 |
+
if st.button("عربي"):
|
| 21 |
+
st.session_state.language = "arabic"
|
| 22 |
+
|
| 23 |
+
# Dil seçimi yapılmışsa, uygun programı çalıştır
|
| 24 |
+
else:
|
| 25 |
+
if st.session_state.language == "turkish":
|
| 26 |
+
import turkce # Türkçe programı çağır
|
| 27 |
+
elif st.session_state.language == "english":
|
| 28 |
+
import english # İngilizce programı çağır
|
| 29 |
+
elif st.session_state.language == "arabic":
|
| 30 |
+
import arabic # Arapça programı çağır
|
arapca.py
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
| 8 |
+
st.title("تطبيق محلل الدرجات باستخدام Streamlit")
|
| 9 |
+
|
| 10 |
+
# حالة عرض الصور
|
| 11 |
+
if "show_images" not in st.session_state:
|
| 12 |
+
st.session_state.show_images = True # الافتراضي: يتم عرض الصور
|
| 13 |
+
|
| 14 |
+
# منطقة إدخال البيانات في الشريط الجانبي
|
| 15 |
+
st.sidebar.header("حقول الإدخال")
|
| 16 |
+
|
| 17 |
+
# اختيار رفع ملف أو إدخال النصوص يدويًا
|
| 18 |
+
input_method = st.sidebar.radio(
|
| 19 |
+
"كيف ستقدم الدرجات؟",
|
| 20 |
+
options=["رفع ملف", "نسخ ولصق"]
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
uploaded_file = None
|
| 24 |
+
text_input = None
|
| 25 |
+
|
| 26 |
+
if input_method == "رفع ملف":
|
| 27 |
+
uploaded_file = st.sidebar.file_uploader("قم برفع ملف الدرجات (TXT)", type=["txt"])
|
| 28 |
+
elif input_method == "نسخ ولصق":
|
| 29 |
+
text_input = st.sidebar.text_area("قم بلصق الدرجات هنا", height=200)
|
| 30 |
+
|
| 31 |
+
# المعلمات الأخرى
|
| 32 |
+
lecture_name = st.sidebar.text_input("اسم المادة", value="اسم المادة")
|
| 33 |
+
perfect_score = st.sidebar.number_input("الدرجة الكاملة", value=100, step=1)
|
| 34 |
+
my_note = st.sidebar.number_input("درجتي", value=0.0, step=0.1)
|
| 35 |
+
note_s_axis_diff = st.sidebar.number_input("حجم خطوات المحور السيني للدرجات", value=5, step=1)
|
| 36 |
+
amount_s_axis_diff = st.sidebar.number_input("حجم خطوات المحور الصادي للتكرار", value=1, step=1)
|
| 37 |
+
first_step = st.sidebar.number_input("الخطوة الأولى", value=0, step=1)
|
| 38 |
+
increase_amount = st.sidebar.number_input("مقدار الزيادة", value=1, step=1)
|
| 39 |
+
|
| 40 |
+
if st.sidebar.button("تشغيل التحليل"):
|
| 41 |
+
# إخفاء الصور عند النقر على الزر
|
| 42 |
+
st.session_state.show_images = False
|
| 43 |
+
|
| 44 |
+
# عرض الصور فقط إذا كانت show_images صحيحة
|
| 45 |
+
if st.session_state.show_images:
|
| 46 |
+
st.subheader("كيفية عمل التطبيق")
|
| 47 |
+
|
| 48 |
+
# قائمة بأسماء ملفات الصور بالترتيب
|
| 49 |
+
image_files = ["arabic/a.png", "arabic/b.png", "arabic/c.png", "arabic/d.png"]
|
| 50 |
+
|
| 51 |
+
# عرض الصور واحدة تحت الأخرى
|
| 52 |
+
for image_file in image_files:
|
| 53 |
+
st.image(image_file, use_container_width=True)
|
| 54 |
+
|
| 55 |
+
# تحميل ومعالجة الدرجات (يعمل فقط إذا تم النقر على الزر)
|
| 56 |
+
if not st.session_state.show_images:
|
| 57 |
+
if input_method == "رفع ملف" and uploaded_file is None:
|
| 58 |
+
st.error("يرجى رفع ملف!")
|
| 59 |
+
elif input_method == "نسخ ولصق" and not text_input:
|
| 60 |
+
st.error("يرجى لصق الدرجات في مربع النص!")
|
| 61 |
+
else:
|
| 62 |
+
try:
|
| 63 |
+
# قراءة المحتوى من الملف أو مربع النص
|
| 64 |
+
if uploaded_file:
|
| 65 |
+
content = uploaded_file.read().decode("utf-8")
|
| 66 |
+
elif text_input:
|
| 67 |
+
content = text_input
|
| 68 |
+
|
| 69 |
+
# معالجة البيانات
|
| 70 |
+
result = re.split(r'[ \n]+', content)
|
| 71 |
+
|
| 72 |
+
# تنظيف وتصنيف البيانات
|
| 73 |
+
notes_result = [x.strip() for x in result[first_step::increase_amount] if x.strip() != '∅' and x.strip() != "NA"]
|
| 74 |
+
notes_result = list(map(lambda x: float(x), notes_result))
|
| 75 |
+
notes_result = np.array(notes_result)
|
| 76 |
+
|
| 77 |
+
# الإحصائيات
|
| 78 |
+
average_x = np.average(notes_result)
|
| 79 |
+
min_x = notes_result.min()
|
| 80 |
+
max_x = notes_result.max()
|
| 81 |
+
std = np.std(notes_result)
|
| 82 |
+
z_score = (my_note - average_x) / std
|
| 83 |
+
|
| 84 |
+
# عرض الإحصائيات
|
| 85 |
+
st.subheader("المعلومات العامة")
|
| 86 |
+
st.write(f"عدد المشاركين: {len(notes_result)}")
|
| 87 |
+
st.write(f"أقل درجة: {min_x:.2f}")
|
| 88 |
+
st.write(f"أعلى درجة: {max_x:.2f}")
|
| 89 |
+
st.write(f"متوسط الدرجات: {average_x:.2f}")
|
| 90 |
+
st.write(f"الانحراف المعياري: {std:.2f}")
|
| 91 |
+
st.write(f"درجة Z: {z_score:.2f}")
|
| 92 |
+
|
| 93 |
+
# إنشاء الرسم البياني
|
| 94 |
+
st.subheader("رسم توزيع الدرجات")
|
| 95 |
+
unique_values, counts = np.unique(notes_result, return_counts=True)
|
| 96 |
+
plt.figure(figsize=(10, 6))
|
| 97 |
+
bars = plt.bar(unique_values, counts, width=0.3)
|
| 98 |
+
plt.axvline(x=average_x, color='red', linestyle='--')
|
| 99 |
+
plt.text(average_x + 1.5, max(counts), 'متوسط الدرجات', color='red', rotation=0, ha='center', va='bottom')
|
| 100 |
+
|
| 101 |
+
if my_note in unique_values:
|
| 102 |
+
plt.text(my_note, counts[unique_values == my_note][0], 'درجتي', color='green', rotation=0, ha='center', va='bottom')
|
| 103 |
+
|
| 104 |
+
for bar in bars:
|
| 105 |
+
if bar.get_x() <= my_note < bar.get_x() + bar.get_width():
|
| 106 |
+
bar.set_color('green')
|
| 107 |
+
|
| 108 |
+
plt.title(f'رسم توزيع الدرجات لمادة {lecture_name}')
|
| 109 |
+
plt.xlabel('الدرجات')
|
| 110 |
+
plt.ylabel('التكرار')
|
| 111 |
+
plt.xticks(range(0, int(perfect_score), note_s_axis_diff), rotation=90)
|
| 112 |
+
plt.yticks(range(0, max(counts), amount_s_axis_diff), rotation=0)
|
| 113 |
+
|
| 114 |
+
# إضافة معلومات إلى الرسم البياني
|
| 115 |
+
info_text = (
|
| 116 |
+
f"عدد المشاركين: {len(notes_result)}\n"
|
| 117 |
+
f"أقل درجة: {min_x:.2f}\n"
|
| 118 |
+
f"أعلى درجة: {max_x:.2f}\n"
|
| 119 |
+
f"درجتي: {my_note:.2f}\n"
|
| 120 |
+
f"متوسط الدرجات: {average_x:.2f}\n"
|
| 121 |
+
f"الانحراف المعياري: {std:.2f}\n"
|
| 122 |
+
f"درجة Z: {z_score:.2f}"
|
| 123 |
+
)
|
| 124 |
+
plt.text(
|
| 125 |
+
1.05 * max(unique_values), 0.8 * max(counts),
|
| 126 |
+
info_text,
|
| 127 |
+
fontsize=10,
|
| 128 |
+
color="black",
|
| 129 |
+
ha="left",
|
| 130 |
+
va="top",
|
| 131 |
+
bbox=dict(boxstyle="round,pad=0.3", edgecolor="blue", facecolor="lightgrey")
|
| 132 |
+
)
|
| 133 |
+
plt.subplots_adjust(left=0.055, bottom=0.065, right=0.90, top=0.962, wspace=0.2, hspace=0.2)
|
| 134 |
+
|
| 135 |
+
# عرض الرسم البياني
|
| 136 |
+
st.pyplot(plt)
|
| 137 |
+
|
| 138 |
+
# زر لتحميل الرسم البياني
|
| 139 |
+
buf = BytesIO()
|
| 140 |
+
plt.savefig(buf, format="png")
|
| 141 |
+
buf.seek(0)
|
| 142 |
+
st.download_button(
|
| 143 |
+
label="تحميل الرسم البياني",
|
| 144 |
+
data=buf,
|
| 145 |
+
file_name="score_distribution.png",
|
| 146 |
+
mime="image/png"
|
| 147 |
+
)
|
| 148 |
+
|
| 149 |
+
except Exception as e:
|
| 150 |
+
st.error(f"خطأ: {e}")
|
| 151 |
+
|
| 152 |
+
# التذييل
|
| 153 |
+
st.markdown("---")
|
| 154 |
+
st.write("تم التطوير بواسطة: علي جميل أوزدمير")
|
| 155 |
+
st.write("التاريخ: 01.12.2024")
|
| 156 |
+
st.write("للتعليقات والاقتراحات، يمكنك التواصل عبر: alicemilozdemir7@gmail.com")
|
| 157 |
+
|
| 158 |
+
# إضافة ملاحظة أسفل الزاوية اليمنى
|
| 159 |
+
st.markdown("""
|
| 160 |
+
<p style="position:absolute; bottom:0px; right:0px; font-size: 12px; color: gray;">
|
| 161 |
+
تم الإنشاء باستخدام محلل الد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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
# Title
|
| 8 |
+
st.title("Note Analyzer Streamlit Application")
|
| 9 |
+
|
| 10 |
+
# Image display state
|
| 11 |
+
if "show_images" not in st.session_state:
|
| 12 |
+
st.session_state.show_images = True # Default: images are shown
|
| 13 |
+
|
| 14 |
+
# Sidebar input area
|
| 15 |
+
st.sidebar.header("Input Fields")
|
| 16 |
+
|
| 17 |
+
# File upload or text input selection
|
| 18 |
+
input_method = st.sidebar.radio(
|
| 19 |
+
"How will you provide the notes?",
|
| 20 |
+
options=["Upload File", "Copy-Paste"]
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
uploaded_file = None
|
| 24 |
+
text_input = None
|
| 25 |
+
|
| 26 |
+
if input_method == "Upload File":
|
| 27 |
+
uploaded_file = st.sidebar.file_uploader("Upload the Notes File (TXT)", type=["txt"])
|
| 28 |
+
elif input_method == "Copy-Paste":
|
| 29 |
+
text_input = st.sidebar.text_area("Paste the Notes Here", height=200)
|
| 30 |
+
|
| 31 |
+
# Other parameters
|
| 32 |
+
lecture_name = st.sidebar.text_input("Course Name", value="Course Name")
|
| 33 |
+
perfect_score = st.sidebar.number_input("Maximum Exam Score", value=100, step=1)
|
| 34 |
+
my_note = st.sidebar.number_input("My Score", value=0.0, step=0.1)
|
| 35 |
+
note_s_axis_diff = st.sidebar.number_input("Score X-Axis Step Size", value=5, step=1)
|
| 36 |
+
amount_s_axis_diff = st.sidebar.number_input("Frequency Y-Axis Step Size", value=1, step=1)
|
| 37 |
+
first_step = st.sidebar.number_input("First Step", value=0, step=1)
|
| 38 |
+
increase_amount = st.sidebar.number_input("Step Increase", value=1, step=1)
|
| 39 |
+
|
| 40 |
+
if st.sidebar.button("Run Analysis"):
|
| 41 |
+
# Hide images when the button is clicked
|
| 42 |
+
st.session_state.show_images = False
|
| 43 |
+
|
| 44 |
+
# Show images only if show_images is True
|
| 45 |
+
if st.session_state.show_images:
|
| 46 |
+
st.subheader("How the Application Works")
|
| 47 |
+
|
| 48 |
+
# List the image filenames in order
|
| 49 |
+
image_files = ["english/a.png", "english/b.png", "english/c.png", "english/d.png"]
|
| 50 |
+
|
| 51 |
+
# Display images one below the other
|
| 52 |
+
for image_file in image_files:
|
| 53 |
+
st.image(image_file, use_container_width=True)
|
| 54 |
+
|
| 55 |
+
# Load and process notes (Only works if the button is clicked)
|
| 56 |
+
if not st.session_state.show_images:
|
| 57 |
+
if input_method == "Upload File" and uploaded_file is None:
|
| 58 |
+
st.error("Please upload a file!")
|
| 59 |
+
elif input_method == "Copy-Paste" and not text_input:
|
| 60 |
+
st.error("Please paste the notes into the text area!")
|
| 61 |
+
else:
|
| 62 |
+
try:
|
| 63 |
+
# Read content from file or text area
|
| 64 |
+
if uploaded_file:
|
| 65 |
+
content = uploaded_file.read().decode("utf-8")
|
| 66 |
+
elif text_input:
|
| 67 |
+
content = text_input
|
| 68 |
+
|
| 69 |
+
# Process the data
|
| 70 |
+
result = re.split(r'[ \n]+', content)
|
| 71 |
+
|
| 72 |
+
# Clean and filter the data
|
| 73 |
+
notes_result = [x.strip() for x in result[first_step::increase_amount] if x.strip() != '∅' and x.strip() != "NA"]
|
| 74 |
+
notes_result = list(map(lambda x: float(x), notes_result))
|
| 75 |
+
notes_result = np.array(notes_result)
|
| 76 |
+
|
| 77 |
+
# Statistics
|
| 78 |
+
average_x = np.average(notes_result)
|
| 79 |
+
min_x = notes_result.min()
|
| 80 |
+
max_x = notes_result.max()
|
| 81 |
+
std = np.std(notes_result)
|
| 82 |
+
z_score = (my_note - average_x) / std
|
| 83 |
+
|
| 84 |
+
# Display statistics
|
| 85 |
+
st.subheader("General Information")
|
| 86 |
+
st.write(f"Number of Participants: {len(notes_result)}")
|
| 87 |
+
st.write(f"Lowest Score: {min_x:.2f}")
|
| 88 |
+
st.write(f"Highest Score: {max_x:.2f}")
|
| 89 |
+
st.write(f"Average Score: {average_x:.2f}")
|
| 90 |
+
st.write(f"Standard Deviation: {std:.2f}")
|
| 91 |
+
st.write(f"Z-Score: {z_score:.2f}")
|
| 92 |
+
|
| 93 |
+
# Create plot
|
| 94 |
+
st.subheader("Score Distribution Graph")
|
| 95 |
+
unique_values, counts = np.unique(notes_result, return_counts=True)
|
| 96 |
+
plt.figure(figsize=(10, 6))
|
| 97 |
+
bars = plt.bar(unique_values, counts, width=0.3)
|
| 98 |
+
plt.axvline(x=average_x, color='red', linestyle='--')
|
| 99 |
+
plt.text(average_x + 1.5, max(counts), 'Average Score', color='red', rotation=0, ha='center', va='bottom')
|
| 100 |
+
|
| 101 |
+
if my_note in unique_values:
|
| 102 |
+
plt.text(my_note, counts[unique_values == my_note][0], 'My\nScore', color='green', rotation=0, ha='center', va='bottom')
|
| 103 |
+
|
| 104 |
+
for bar in bars:
|
| 105 |
+
if bar.get_x() <= my_note < bar.get_x() + bar.get_width():
|
| 106 |
+
bar.set_color('green')
|
| 107 |
+
|
| 108 |
+
plt.title(f'{lecture_name} Score Distribution')
|
| 109 |
+
plt.xlabel('Scores')
|
| 110 |
+
plt.ylabel('Count')
|
| 111 |
+
plt.xticks(range(0, int(perfect_score), note_s_axis_diff), rotation=90)
|
| 112 |
+
plt.yticks(range(0, max(counts), amount_s_axis_diff), rotation=0)
|
| 113 |
+
|
| 114 |
+
# Add graph information
|
| 115 |
+
info_text = (
|
| 116 |
+
f"Number of participants: {len(notes_result)}\n"
|
| 117 |
+
f"Lowest score: {min_x:.2f}\n"
|
| 118 |
+
f"Highest score: {max_x:.2f}\n"
|
| 119 |
+
f"My score: {my_note:.2f}\n"
|
| 120 |
+
f"Average score: {average_x:.2f}\n"
|
| 121 |
+
f"Standard deviation: {std:.2f}\n"
|
| 122 |
+
f"Z-score: {z_score:.2f}"
|
| 123 |
+
)
|
| 124 |
+
plt.text(
|
| 125 |
+
1.05 * max(unique_values), 0.8 * max(counts),
|
| 126 |
+
info_text,
|
| 127 |
+
fontsize=10,
|
| 128 |
+
color="black",
|
| 129 |
+
ha="left",
|
| 130 |
+
va="top",
|
| 131 |
+
bbox=dict(boxstyle="round,pad=0.3", edgecolor="blue", facecolor="lightgrey")
|
| 132 |
+
)
|
| 133 |
+
plt.subplots_adjust(left=0.055, bottom=0.065, right=0.90, top=0.962, wspace=0.2, hspace=0.2)
|
| 134 |
+
|
| 135 |
+
# Display the plot
|
| 136 |
+
st.pyplot(plt)
|
| 137 |
+
|
| 138 |
+
# Download button for the plot
|
| 139 |
+
buf = BytesIO()
|
| 140 |
+
plt.savefig(buf, format="png")
|
| 141 |
+
buf.seek(0)
|
| 142 |
+
st.download_button(
|
| 143 |
+
label="Download Graph",
|
| 144 |
+
data=buf,
|
| 145 |
+
file_name="score_distribution.png",
|
| 146 |
+
mime="image/png"
|
| 147 |
+
)
|
| 148 |
+
|
| 149 |
+
except Exception as e:
|
| 150 |
+
st.error(f"Error: {e}")
|
| 151 |
+
|
| 152 |
+
# Footer
|
| 153 |
+
st.markdown("---")
|
| 154 |
+
st.write("Developed by: Ali Cemil Özdemir")
|
| 155 |
+
st.write("Date: 01.12.2024")
|
| 156 |
+
st.write("For feedback and suggestions, you can contact me at alicemilozdemir7@gmail.com")
|
| 157 |
+
|
| 158 |
+
# Add a note at the bottom right corner of the page
|
| 159 |
+
st.markdown("""
|
| 160 |
+
<p style="position:absolute; bottom:0px; right:0px; font-size: 12px; color: gray;">
|
| 161 |
+
Created with Note Analyzer
|
| 162 |
+
</p>
|
| 163 |
+
""", unsafe_allow_html=True)
|
turkce.py
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
# Başlık
|
| 8 |
+
st.title("Note Analyzer Streamlit Uygulaması")
|
| 9 |
+
|
| 10 |
+
# Uygulamanın çalışma prensibi görüntüleme durumu
|
| 11 |
+
if "show_images" not in st.session_state:
|
| 12 |
+
st.session_state.show_images = True # Varsayılan olarak resimler gösterilsin
|
| 13 |
+
|
| 14 |
+
# Kullanıcıdan veri alma (Sidebar sabit kalıyor)
|
| 15 |
+
st.sidebar.header("Girdi Alanları")
|
| 16 |
+
|
| 17 |
+
# Dosya yükleme veya metin girişi seçimi
|
| 18 |
+
input_method = st.sidebar.radio(
|
| 19 |
+
"Notları nasıl gireceksiniz?",
|
| 20 |
+
options=["Dosya Yükle", "Kopyala-Yapıştır"]
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
uploaded_file = None
|
| 24 |
+
text_input = None
|
| 25 |
+
|
| 26 |
+
if input_method == "Dosya Yükle":
|
| 27 |
+
uploaded_file = st.sidebar.file_uploader("Notlar Dosyasını Yükleyin (TXT)", type=["txt"])
|
| 28 |
+
elif input_method == "Kopyala-Yapıştır":
|
| 29 |
+
text_input = st.sidebar.text_area("Notları Yapıştırın", height=200)
|
| 30 |
+
|
| 31 |
+
# Diğer parametreler
|
| 32 |
+
lecture_name = st.sidebar.text_input("Ders Adı", value="Ders Adı")
|
| 33 |
+
perfect_score = st.sidebar.number_input("Sınav Puanı Üst Limiti", value=100, step=1)
|
| 34 |
+
my_note = st.sidebar.number_input("Benim Notum", value=0.0, step=0.1)
|
| 35 |
+
note_s_axis_diff = st.sidebar.number_input("Notlar X Ekseni Ortak Farkı", value=5, step=1)
|
| 36 |
+
amount_s_axis_diff = st.sidebar.number_input("Miktar Y Ekseni Ortak Farkı", value=1, step=1)
|
| 37 |
+
first_step = st.sidebar.number_input("İlk Adım", value=0, step=1)
|
| 38 |
+
increase_amount = st.sidebar.number_input("Artış Miktarı", value=1, step=1)
|
| 39 |
+
|
| 40 |
+
if st.sidebar.button("Analizi Çalıştır"):
|
| 41 |
+
# Butona basıldığında resimleri gizle
|
| 42 |
+
st.session_state.show_images = False
|
| 43 |
+
|
| 44 |
+
# Resimler yalnızca show_images True ise gösterilir
|
| 45 |
+
if st.session_state.show_images:
|
| 46 |
+
st.subheader("Uygulamanın Çalışma Prensibi")
|
| 47 |
+
|
| 48 |
+
# Resimlerin dosya isimlerini sırayla listele
|
| 49 |
+
image_files = ["turkish/a.png", "turkish/b.png", "turkish/c.png", "turkish/d.png"]
|
| 50 |
+
|
| 51 |
+
# Resimleri alt alta ekle
|
| 52 |
+
for image_file in image_files:
|
| 53 |
+
st.image(image_file, use_container_width=True)
|
| 54 |
+
|
| 55 |
+
# Notları yükleme ve işleme işlemleri (Butona basıldıysa çalışır)
|
| 56 |
+
if not st.session_state.show_images:
|
| 57 |
+
if input_method == "Dosya Yükle" and uploaded_file is None:
|
| 58 |
+
st.error("Lütfen bir dosya yükleyin!")
|
| 59 |
+
elif input_method == "Kopyala-Yapıştır" and not text_input:
|
| 60 |
+
st.error("Lütfen notları metin kutusuna yapıştırın!")
|
| 61 |
+
else:
|
| 62 |
+
try:
|
| 63 |
+
# Dosya veya metin kutusundan içerik okuma
|
| 64 |
+
if uploaded_file:
|
| 65 |
+
content = uploaded_file.read().decode("utf-8")
|
| 66 |
+
elif text_input:
|
| 67 |
+
content = text_input
|
| 68 |
+
|
| 69 |
+
# Veriyi işleme
|
| 70 |
+
result = re.split(r'[ \n]+', content)
|
| 71 |
+
|
| 72 |
+
# Strip fonksiyonu ve kaçış dizisi temizliği
|
| 73 |
+
notes_result = [x.strip() for x in result[first_step::increase_amount] if x.strip() != '∅' and x.strip() != "NA"]
|
| 74 |
+
notes_result = list(map(lambda x: float(x), notes_result))
|
| 75 |
+
notes_result = np.array(notes_result)
|
| 76 |
+
|
| 77 |
+
# İstatistikler
|
| 78 |
+
average_x = np.average(notes_result)
|
| 79 |
+
min_x = notes_result.min()
|
| 80 |
+
max_x = notes_result.max()
|
| 81 |
+
std = np.std(notes_result)
|
| 82 |
+
z_score = (my_note - average_x) / std
|
| 83 |
+
|
| 84 |
+
# İstatistikleri ekrana yazdırma
|
| 85 |
+
st.subheader("Genel Bilgiler")
|
| 86 |
+
st.write(f"Katilimci Sayısı: {len(notes_result)}")
|
| 87 |
+
st.write(f"En Düşük Not: {min_x:.2f}")
|
| 88 |
+
st.write(f"En Yüksek Not: {max_x:.2f}")
|
| 89 |
+
st.write(f"Ortalama Not: {average_x:.2f}")
|
| 90 |
+
st.write(f"Standart Sapma: {std:.2f}")
|
| 91 |
+
st.write(f"Z-Skoru: {z_score:.2f}")
|
| 92 |
+
|
| 93 |
+
# Grafik oluşturma
|
| 94 |
+
st.subheader("Not Dağılım Grafiği")
|
| 95 |
+
unique_values, counts = np.unique(notes_result, return_counts=True)
|
| 96 |
+
plt.figure(figsize=(10, 6))
|
| 97 |
+
bars = plt.bar(unique_values, counts, width=0.3)
|
| 98 |
+
plt.axvline(x=average_x, color='red', linestyle='--')
|
| 99 |
+
plt.text(average_x + 1.5, max(counts), 'Ortalama Not', color='red', rotation=0, ha='center', va='bottom')
|
| 100 |
+
|
| 101 |
+
if my_note in unique_values:
|
| 102 |
+
plt.text(my_note, counts[unique_values == my_note][0], 'Benim\nNotum', color='green', rotation=0, ha='center', va='bottom')
|
| 103 |
+
|
| 104 |
+
for bar in bars:
|
| 105 |
+
if bar.get_x() <= my_note < bar.get_x() + bar.get_width():
|
| 106 |
+
bar.set_color('green')
|
| 107 |
+
|
| 108 |
+
plt.title(f'{lecture_name} Not Sayıları Grafiği')
|
| 109 |
+
plt.xlabel('Notlar')
|
| 110 |
+
plt.ylabel('Adet')
|
| 111 |
+
plt.xticks(range(0, int(perfect_score), note_s_axis_diff), rotation=90)
|
| 112 |
+
plt.yticks(range(0, max(counts), amount_s_axis_diff), rotation=0)
|
| 113 |
+
|
| 114 |
+
# Grafik bilgileri
|
| 115 |
+
info_text = (
|
| 116 |
+
f"Katilimci sayısı: {len(notes_result)}\n"
|
| 117 |
+
f"En düşük not: {min_x:.2f}\n"
|
| 118 |
+
f"En yüksek not: {max_x:.2f}\n"
|
| 119 |
+
f"Benim notum: {my_note:.2f}\n"
|
| 120 |
+
f"Ortalama not: {average_x:.2f}\n"
|
| 121 |
+
f"Standart sapma: {std:.2f}\n"
|
| 122 |
+
f"Z-skoru: {z_score:.2f}"
|
| 123 |
+
)
|
| 124 |
+
plt.text(
|
| 125 |
+
1.05 * max(unique_values), 0.8 * max(counts),
|
| 126 |
+
info_text,
|
| 127 |
+
fontsize=10,
|
| 128 |
+
color="black",
|
| 129 |
+
ha="left",
|
| 130 |
+
va="top",
|
| 131 |
+
bbox=dict(boxstyle="round,pad=0.3", edgecolor="blue", facecolor="lightgrey")
|
| 132 |
+
)
|
| 133 |
+
plt.subplots_adjust(left=0.055, bottom=0.065, right=0.90, top=0.962, wspace=0.2, hspace=0.2)
|
| 134 |
+
|
| 135 |
+
# Grafik gösterimi
|
| 136 |
+
st.pyplot(plt)
|
| 137 |
+
|
| 138 |
+
# Grafik indirme bağlantısı
|
| 139 |
+
buf = BytesIO()
|
| 140 |
+
plt.savefig(buf, format="png")
|
| 141 |
+
buf.seek(0)
|
| 142 |
+
st.download_button(
|
| 143 |
+
label="Grafiği İndir",
|
| 144 |
+
data=buf,
|
| 145 |
+
file_name="not_dagilimi.png",
|
| 146 |
+
mime="image/png"
|
| 147 |
+
)
|
| 148 |
+
|
| 149 |
+
except Exception as e:
|
| 150 |
+
st.error(f"Hata: {e}")
|
| 151 |
+
|
| 152 |
+
# Web sayfasının altına isim ve tarih
|
| 153 |
+
st.markdown("---")
|
| 154 |
+
st.write("Developed by: Ali Cemil Özdemir")
|
| 155 |
+
st.write("Date: 01.12.2024")
|
| 156 |
+
st.write("For feedback and suggestions, you can contact me at alicemilozdemir7@gmail.com")
|
| 157 |
+
|
| 158 |
+
# Grafiklerin sağ alt köşesine yazı ekleme
|
| 159 |
+
st.markdown("""
|
| 160 |
+
<p style="position:absolute; bottom:0px; right:0px; font-size: 12px; color: gray;">
|
| 161 |
+
Created with Note Analyzer
|
| 162 |
+
</p>
|
| 163 |
+
""", unsafe_allow_html=True)
|