Spaces:
Sleeping
Sleeping
parvalijaved
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -27,7 +27,7 @@ else: # Assuming data is a dictionary
|
|
27 |
# Select Chapter
|
28 |
chapter_id = st.selectbox("Select Chapter", sorted(chapters.keys()), format_func=lambda x: f"Chapter {x}")
|
29 |
|
30 |
-
# Display chapter
|
31 |
chapter_details = chapters.get(chapter_id)
|
32 |
if chapter_details:
|
33 |
chapter_summary = chapter_details.get('chapter_summary', 'No summary available')
|
@@ -36,28 +36,31 @@ if chapter_details:
|
|
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
|
47 |
-
|
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
|
57 |
-
st.markdown(f"**Translation
|
58 |
-
|
|
|
59 |
else:
|
60 |
-
st.error("No verses found for this chapter.")
|
61 |
else:
|
62 |
st.error("Chapter details not found.")
|
63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
# Select Chapter
|
28 |
chapter_id = st.selectbox("Select Chapter", sorted(chapters.keys()), format_func=lambda x: f"Chapter {x}")
|
29 |
|
30 |
+
# Display chapter details if available
|
31 |
chapter_details = chapters.get(chapter_id)
|
32 |
if chapter_details:
|
33 |
chapter_summary = chapter_details.get('chapter_summary', 'No summary available')
|
|
|
36 |
|
37 |
# Extract verses for the selected chapter if available
|
38 |
verses = chapter_details.get('verses', [])
|
39 |
+
if isinstance(verses, list) and 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.get(verse_number)
|
47 |
+
if selected_verse:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
st.markdown(f"**Verse {verse_number}**")
|
49 |
+
st.markdown(f"**Sanskrit:**\n\n{selected_verse['text']}")
|
50 |
+
st.markdown(f"**Translation:**\n\n{selected_verse['translation']}")
|
51 |
+
else:
|
52 |
+
st.error("Verse details not found.")
|
53 |
else:
|
54 |
+
st.error("No verses found for this chapter or verses are not in expected format.")
|
55 |
else:
|
56 |
st.error("Chapter details not found.")
|
57 |
|
58 |
+
# Display all verses in the selected chapter if available
|
59 |
+
if isinstance(verses, list) and verses:
|
60 |
+
st.subheader("All Verses in this Chapter")
|
61 |
+
for verse_number in sorted(verses_dict.keys()):
|
62 |
+
verse = verses_dict[verse_number]
|
63 |
+
st.markdown(f"**Verse {verse_number}**")
|
64 |
+
st.markdown(f"**Sanskrit:** {verse['text']}")
|
65 |
+
st.markdown(f"**Translation:** {verse['translation']}")
|
66 |
+
st.markdown("---")
|