sanatan_ai / nalayiram_helper.py
vikramvasudevan's picture
Upload folder using huggingface_hub
a1180f7 verified
raw
history blame
1.72 kB
import json
from dataclasses import dataclass
@dataclass
class Pasuram:
prabandham_code: str
azhwar_name: str
prabandham_name: str
def get_standardized_prabandham_names() -> list[Pasuram]:
"""
Get a list of prabandham names along with the azhwars who authored them in divya_prabandham
"""
with open("./data/azhwars.json", "r", encoding="utf-8") as f:
azhwars = json.load(f)
header = azhwars[0]
rows = azhwars[1:]
final_azhwars = [Pasuram(**dict(zip(header, row))) for row in rows]
return final_azhwars
def get_standardized_azhwar_names() -> list[str]:
"""
Get a list of azhwar names along with the pasurams they have authored in divya_prabandham
"""
with open("./data/azhwars.json", "r", encoding="utf-8") as f:
azhwars = json.load(f)
header = azhwars[0]
rows = azhwars[1:]
final_azhwars = [row[1] for row in rows] ## 2nd field is the azhwar name
return sorted(set(final_azhwars))
def get_standardized_divya_desam_names() -> list[str]:
"""
Get a list of divya desam names in divya_prabandham
"""
with open("./data/divya_desams.json", "r", encoding="utf-8") as f:
divya_desams = json.load(f) # FIXED
selected_fields = [
"title",
"other_names",
"name_ta",
"alwars",
"area",
"state",
"thirukolam",
"direction",
"sampradayam",
"divya_desam",
]
data = [{key : row[key] for key in selected_fields if key in row} for row in divya_desams["pageProps"]["hits"]]
return sorted(set([row["title"] for row in data]))
if __name__ == "__main__":
print(get_standardized_azhwar_names())