metadata
license: cc-by-4.0
Texbooks from openstax.org with their chapters, abstracts and sections.
Stats:
def count_sections(chapters):
for chapter in chapters:
if "sections" in chapter:
n_titles = sum(1 for s in chapter["sections"] if s["title"] is not None and s["title"].strip())
n_paras = sum(1 for s in chapter["sections"] if s["paragraph"] is not None and s["paragraph"].strip())
yield n_titles, n_paras
else:
yield from count_sections(chapter["chapters"])
with open('openstax_books.jsonl') as fin:
total_books = 0
total_titles, total_paras = 0, 0
for line in fin:
book = json.loads(line)
if book["language"] != "en":
continue
total_books += 1
for t, p in count_sections(book["chapters"]):
total_titles += t
total_paras += p
total_books, total_titles, total_paras
(60, 16771, 16165)