Batnini commited on
Commit
d01328f
·
verified ·
1 Parent(s): ed37d44

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -3
app.py CHANGED
@@ -6,7 +6,7 @@ text_gen = ArabicTextGenerator()
6
  quran = QuranSearchEngine()
7
 
8
  with gr.Blocks(title="الأدوات العربية") as app:
9
- # Tab 1: Your Working Arabic Generator (UNTOUCHED)
10
  with gr.Tab("🖊️ مولد النصوص"):
11
  text_input = gr.Textbox(label="النص الأولي")
12
  length_slider = gr.Slider(50, 300, value=100, label="طول النص")
@@ -19,12 +19,12 @@ with gr.Blocks(title="الأدوات العربية") as app:
19
  outputs=text_output
20
  )
21
 
22
- # Tab 2: Quran Surah Viewer (GUARANTEED TO WORK)
23
  with gr.Tab("📖 القرآن الكريم"):
24
  surah_dropdown = gr.Dropdown(
25
  label="اختر سورة",
26
  choices=quran.get_surahs(),
27
- value=quran.get_surahs()[0][1] # Set default to first surah's ID
28
  )
29
  show_btn = gr.Button("عرض السورة")
30
  quran_output = gr.Textbox(label="النص القرآني", lines=15)
@@ -34,5 +34,18 @@ with gr.Blocks(title="الأدوات العربية") as app:
34
  inputs=surah_dropdown,
35
  outputs=quran_output
36
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
  app.launch()
 
6
  quran = QuranSearchEngine()
7
 
8
  with gr.Blocks(title="الأدوات العربية") as app:
9
+ # Tab 1: Arabic Generator (unchanged)
10
  with gr.Tab("🖊️ مولد النصوص"):
11
  text_input = gr.Textbox(label="النص الأولي")
12
  length_slider = gr.Slider(50, 300, value=100, label="طول النص")
 
19
  outputs=text_output
20
  )
21
 
22
+ # Tab 2: Quran Surah Viewer (unchanged)
23
  with gr.Tab("📖 القرآن الكريم"):
24
  surah_dropdown = gr.Dropdown(
25
  label="اختر سورة",
26
  choices=quran.get_surahs(),
27
+ value=quran.get_surahs()[0][1] if quran.get_surahs() else 1
28
  )
29
  show_btn = gr.Button("عرض السورة")
30
  quran_output = gr.Textbox(label="النص القرآني", lines=15)
 
34
  inputs=surah_dropdown,
35
  outputs=quran_output
36
  )
37
+
38
+ # New Tab 3: Quranic Verse Search (Semantic)
39
+ with gr.Tab("🔍 بحث آيات قرآنية"):
40
+ search_input = gr.Textbox(label="أدخل استعلام البحث (مثال: الرحمة والمغفرة)")
41
+ top_k_slider = gr.Slider(1, 10, value=5, label="عدد النتائج")
42
+ search_btn = gr.Button("بحث")
43
+ search_output = gr.Textbox(label="الآيات ذات الصلة", lines=15)
44
+
45
+ search_btn.click(
46
+ quran.search_verses,
47
+ inputs=[search_input, top_k_slider],
48
+ outputs=search_output
49
+ )
50
 
51
  app.launch()