| | --- |
| | license: cc-by-4.0 |
| | --- |
| | |
| | Texbooks from openstax.org with their chapters, abstracts and sections. |
| |
|
| | Sample: |
| | ```json |
| | { |
| | "book_title":"World History Volume 1, to 1500", |
| | "language":"en", |
| | "chapters":[ |
| | { |
| | "title":"Preface", |
| | "abstract":"None", |
| | "sections":[ |
| | { |
| | "title":"About OpenStax", |
| | "paragraph":"OpenStax is part of Rice University, which is a 501(c)(3) nonprofit..." |
| | }, |
| | { |
| | "title":"About OpenStax Resources", |
| | "paragraph":"None" |
| | }, |
| | { |
| | "title":"About *World History*", |
| | "paragraph":"*World History* is designed to support both semesters of the world history course..." |
| | }, |
| | { |
| | "title":"Pedagogical Foundation", |
| | "paragraph":"None" |
| | }, |
| | { |
| | "title":"Answers to Questions in the Book", |
| | "paragraph":"The end-of-chapter Review, Check Your Understanding, and Reflection Questions are intended for..." |
| | }, |
| | ``` |
| |
|
| | Stats: |
| | ```python |
| | 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) |
| | ``` |