Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,35 @@
|
|
1 |
---
|
2 |
license: cc-by-4.0
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: cc-by-4.0
|
3 |
---
|
4 |
+
|
5 |
+
Texbooks from openstax.org with their chapters, abstracts and sections.
|
6 |
+
|
7 |
+
Stats:
|
8 |
+
```python
|
9 |
+
def count_sections(chapters):
|
10 |
+
for chapter in chapters:
|
11 |
+
if "sections" in chapter:
|
12 |
+
n_titles = sum(1 for s in chapter["sections"] if s["title"] is not None and s["title"].strip())
|
13 |
+
n_paras = sum(1 for s in chapter["sections"] if s["paragraph"] is not None and s["paragraph"].strip())
|
14 |
+
yield n_titles, n_paras
|
15 |
+
else:
|
16 |
+
yield from count_sections(chapter["chapters"])
|
17 |
+
|
18 |
+
with open('openstax_books.jsonl') as fin:
|
19 |
+
total_books = 0
|
20 |
+
total_titles, total_paras = 0, 0
|
21 |
+
for line in fin:
|
22 |
+
book = json.loads(line)
|
23 |
+
if book["language"] != "en":
|
24 |
+
continue
|
25 |
+
total_books += 1
|
26 |
+
for t, p in count_sections(book["chapters"]):
|
27 |
+
total_titles += t
|
28 |
+
total_paras += p
|
29 |
+
|
30 |
+
total_books, total_titles, total_paras
|
31 |
+
```
|
32 |
+
|
33 |
+
```
|
34 |
+
(60, 16771, 16165)
|
35 |
+
```
|