forked from Sefaria/Sefaria-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbookworm_list.py
37 lines (30 loc) · 956 Bytes
/
bookworm_list.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import json
from sefaria.model import *
from sefaria.summaries import *
from sefaria.local_settings import SEFARIA_DATA_PATH
toc = get_toc()
flat_toc = flatten_toc(toc)
bookworm = []
commentary = []
for title in flat_toc:
i = get_index(title)
if i.categories[0] == "Tanach":
cat = i.categories[1]
elif i.categories[0] == "Talmud":
cat = "Talmud " + i.categories[1]
elif i.categories[0] == "Commentary2":
cat = "Commentary"
elif i.categories[0] == "Other" and i.categories[1] == "Maharsha":
cat = "Commentary"
elif i.categories[0] == "Other":
cat = i.categories[0]
else:
cat = i.categories[0]
item = {"title": title, "category": cat}
if cat == "Commentary":
commentary.append(item)
else:
bookworm.append(item)
bookworm += commentary
with open(SEFARIA_DATA_PATH + "misc/bookworm_list.json", "w") as f:
f.write(json.dumps(bookworm, indent=4))