Spaces:
Sleeping
Sleeping
parvalijaved
commited on
Update app.py
Browse files
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 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
st.
|
44 |
-
|
45 |
-
# Display
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|