File size: 1,961 Bytes
10d6fb6 ccc8e61 d336e6a ccc8e61 |
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
---
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)
``` |