parvalijaved commited on
Commit
9c855f4
·
verified ·
1 Parent(s): 3916b69

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -22
app.py CHANGED
@@ -28,25 +28,36 @@ else: # Assuming data is a dictionary
28
  chapter_id = st.selectbox("Select Chapter", sorted(chapters.keys()), format_func=lambda x: f"Chapter {x}")
29
 
30
  # Display chapter summary if available
31
- chapter_summary = chapters[chapter_id].get('chapter_summary', 'No summary available')
32
- st.subheader(f"Chapter {chapter_id}")
33
- st.markdown(f"**Summary:**\n\n{chapter_summary}")
34
-
35
- # Extract verses for the selected chapter
36
- verses = {verse['verse_number']: verse for verse in chapters[chapter_id]['verses']}
37
- verse_number = st.selectbox("Select Verse", sorted(verses.keys()))
38
-
39
- # Display selected verse
40
- selected_verse = verses[verse_number]
41
- st.markdown(f"**Verse {verse_number}**")
42
- st.markdown(f"**Sanskrit:**\n\n{selected_verse['text']}")
43
- st.markdown(f"**Translation:**\n\n{selected_verse['translation']}")
44
-
45
- # Display all verses in the selected chapter
46
- st.subheader("All Verses in this Chapter")
47
- for verse_number in sorted(verses.keys()):
48
- verse = verses[verse_number]
49
- st.markdown(f"**Verse {verse_number}**")
50
- st.markdown(f"**Sanskrit:** {verse['text']}")
51
- st.markdown(f"**Translation:** {verse['translation']}")
52
- st.markdown("---")
 
 
 
 
 
 
 
 
 
 
 
 
28
  chapter_id = st.selectbox("Select Chapter", sorted(chapters.keys()), format_func=lambda x: f"Chapter {x}")
29
 
30
  # Display chapter summary if available
31
+ chapter_details = chapters.get(chapter_id)
32
+ if chapter_details:
33
+ chapter_summary = chapter_details.get('chapter_summary', 'No summary available')
34
+ st.subheader(f"Chapter {chapter_id}")
35
+ st.markdown(f"**Summary:**\n\n{chapter_summary}")
36
+
37
+ # Extract verses for the selected chapter if available
38
+ verses = chapter_details.get('verses', [])
39
+ if verses:
40
+ verses_dict = {verse['verse_number']: verse for verse in verses}
41
+
42
+ # Select Verse
43
+ verse_number = st.selectbox("Select Verse", sorted(verses_dict.keys()))
44
+
45
+ # Display selected verse
46
+ selected_verse = verses_dict[verse_number]
47
+ st.markdown(f"**Verse {verse_number}**")
48
+ st.markdown(f"**Sanskrit:**\n\n{selected_verse['text']}")
49
+ st.markdown(f"**Translation:**\n\n{selected_verse['translation']}")
50
+
51
+ # Display all verses in the selected chapter
52
+ st.subheader("All Verses in this Chapter")
53
+ for verse_number in sorted(verses_dict.keys()):
54
+ verse = verses_dict[verse_number]
55
+ st.markdown(f"**Verse {verse_number}**")
56
+ st.markdown(f"**Sanskrit:** {verse['text']}")
57
+ st.markdown(f"**Translation:** {verse['translation']}")
58
+ st.markdown("---")
59
+ else:
60
+ st.error("No verses found for this chapter.")
61
+ else:
62
+ st.error("Chapter details not found.")
63
+