Update app.py
Browse files
app.py
CHANGED
@@ -2,9 +2,9 @@ import gradio as gr
|
|
2 |
import matplotlib.pyplot as plt
|
3 |
import wikipedia
|
4 |
import random
|
5 |
-
from
|
6 |
|
7 |
-
|
8 |
wikipedia.set_lang("tr")
|
9 |
|
10 |
# Türk devletlerinin listesi (17 devlet)
|
@@ -556,25 +556,12 @@ def get_state_summary_cached(state):
|
|
556 |
summary = "Bu konuda Wikipedia'da uygun bir sayfa bulunamadı."
|
557 |
except Exception as e:
|
558 |
summary = f"Özet bilgi çekilemedi: {e}"
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
# Eğer seçilen devlet için hazır soru varsa, onu döndür.
|
566 |
-
if state in predefined_questions:
|
567 |
-
return predefined_questions[state]
|
568 |
-
else:
|
569 |
-
# Eğer hazır soru yoksa, 10 adet dummy soru oluştur.
|
570 |
-
questions = []
|
571 |
-
for i in range(10):
|
572 |
-
questions.append({
|
573 |
-
"question": f"Dummy soru {i+1}: {state} hakkında önemli bilgi nedir?",
|
574 |
-
"options": ["Seçenek A", "Seçenek B", "Seçenek C", "Seçenek D"],
|
575 |
-
"correct": "A"
|
576 |
-
})
|
577 |
-
return questions
|
578 |
|
579 |
# Global öğrenci verilerini saklamak için değişken.
|
580 |
student_data = {}
|
@@ -583,7 +570,16 @@ def load_history(name, state):
|
|
583 |
student_data["name"] = name
|
584 |
student_data["state"] = state
|
585 |
summary = get_state_summary_cached(state)
|
586 |
-
questions =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
587 |
student_data["questions"] = questions
|
588 |
updates = []
|
589 |
for q in questions:
|
@@ -661,4 +657,4 @@ with gr.Blocks() as demo:
|
|
661 |
outputs=[score_display, medal_display, chart_display]
|
662 |
)
|
663 |
|
664 |
-
demo.launch()
|
|
|
2 |
import matplotlib.pyplot as plt
|
3 |
import wikipedia
|
4 |
import random
|
5 |
+
from deep_translator import GoogleTranslator
|
6 |
|
7 |
+
# Wikipedia özetlerini Türkçe çekebilmek için dili ayarlıyoruz.
|
8 |
wikipedia.set_lang("tr")
|
9 |
|
10 |
# Türk devletlerinin listesi (17 devlet)
|
|
|
556 |
summary = "Bu konuda Wikipedia'da uygun bir sayfa bulunamadı."
|
557 |
except Exception as e:
|
558 |
summary = f"Özet bilgi çekilemedi: {e}"
|
559 |
+
# Çeviri: Eğer metin İngilizce ise Türkçeye çevir.
|
560 |
+
try:
|
561 |
+
translated = GoogleTranslator(source='auto', target='tr').translate(summary)
|
562 |
+
return translated
|
563 |
+
except Exception as e:
|
564 |
+
return summary
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
565 |
|
566 |
# Global öğrenci verilerini saklamak için değişken.
|
567 |
student_data = {}
|
|
|
570 |
student_data["name"] = name
|
571 |
student_data["state"] = state
|
572 |
summary = get_state_summary_cached(state)
|
573 |
+
questions = predefined_questions.get(state, None)
|
574 |
+
if questions is None:
|
575 |
+
# Eğer hazır soru yoksa, 10 adet dummy soru oluştur.
|
576 |
+
questions = []
|
577 |
+
for i in range(10):
|
578 |
+
questions.append({
|
579 |
+
"question": f"{state} tarihinin önemli olaylarından hangisi aşağıdakilerden biri olabilir?",
|
580 |
+
"options": [f"{state} Olay A", f"{state} Olay B", f"{state} Olay C", f"{state} Olay D"],
|
581 |
+
"correct": "A"
|
582 |
+
})
|
583 |
student_data["questions"] = questions
|
584 |
updates = []
|
585 |
for q in questions:
|
|
|
657 |
outputs=[score_display, medal_display, chart_display]
|
658 |
)
|
659 |
|
660 |
+
demo.launch()
|