Datasets:
Tasks:
Text Generation
Modalities:
Text
Formats:
parquet
Sub-tasks:
language-modeling
Languages:
Danish
Size:
100K - 1M
License:
KennethEnevoldsen
commited on
Commit
•
f2ad4e1
1
Parent(s):
1e0f4c0
update descriptive stats
Browse files- CONTRIBUTING.md +1 -0
- README.md +12 -5
- data/adl/adl.md +3 -2
- data/adl/descriptive_stats.json +1 -0
- data/botxt/botxt.md +3 -2
- data/botxt/descriptive_stats.json +1 -0
- data/dannet/dannet.md +3 -2
- data/dannet/descriptive_stats.json +1 -0
- data/depbank/descriptive_stats.json +1 -0
- data/ep/descriptive_stats.json +1 -0
- data/ft/descriptive_stats.json +1 -0
- data/ft/ft.md +3 -2
- data/gutenberg/descriptive_stats.json +1 -0
- data/hest/descriptive_stats.json +1 -0
- data/jvj/descriptive_stats.json +1 -0
- data/naat/descriptive_stats.json +1 -0
- data/naat/naat.md +3 -2
- data/nordjyllandnews/descriptive_stats.json +1 -0
- data/nordjyllandnews/nordjyllandnews.md +3 -2
- data/relig/descriptive_stats.json +1 -0
- data/relig/relig.md +11 -2
- data/retsinformationdk/descriptive_stats.json +1 -0
- data/retspraksis/descriptive_stats.json +1 -0
- data/retspraksis/retspraksis.md +3 -2
- data/skat/descriptive_stats.json +1 -0
- data/skat/skat.md +3 -2
- data/spont/descriptive_stats.json +1 -0
- data/synne/descriptive_stats.json +1 -0
- data/synne/synne.md +3 -2
- data/tv2r/descriptive_stats.json +1 -0
- data/wiki/descriptive_stats.json +1 -0
- data/wikibooks/descriptive_stats.json +1 -0
- data/wikisource/descriptive_stats.json +1 -0
- data/wikisource/wikisource.md +2 -0
- descriptive_stats.json +1 -0
- pyproject.toml +1 -0
- scripts/git_utilities.py +26 -0
- scripts/update_descriptive_statistics.py +107 -12
- tests/conftest.py +8 -9
- uv.lock +39 -4
CONTRIBUTING.md
CHANGED
@@ -54,3 +54,4 @@ Before you make the PR do be sure to make sure that the tests have been run.
|
|
54 |
To see example PR you can see the following:
|
55 |
|
56 |
- [Restructuring columns in the dataset](https://huggingface.co/datasets/danish-foundation-models/danish-dynaword/discussions/11)
|
|
|
|
54 |
To see example PR you can see the following:
|
55 |
|
56 |
- [Restructuring columns in the dataset](https://huggingface.co/datasets/danish-foundation-models/danish-dynaword/discussions/11)
|
57 |
+
- [Adding a new dataset](https://huggingface.co/datasets/danish-foundation-models/danish-dynaword/discussions/15)
|
README.md
CHANGED
@@ -116,11 +116,11 @@ https://github.com/huggingface/datasets/blob/main/templates/README_guide.md -->
|
|
116 |
|
117 |
# 🧨 Danish Dynaword
|
118 |
|
119 |
-
| |
|
120 |
-
| ------------ |
|
121 |
-
| **Language** | dan, dansk, Danish
|
122 |
-
| **License** | Permissible, See the respective dataset
|
123 |
-
| **Models** | For model trained used this data see [danish-foundation-models](https://huggingface.co/danish-foundation-models)
|
124 |
| **Contact** | If you have question about this project please create an issue [here](https://huggingface.co/datasets/danish-foundation-models/danish-dynaword/discussions) |
|
125 |
|
126 |
|
@@ -145,6 +145,13 @@ https://github.com/huggingface/datasets/blob/main/templates/README_guide.md -->
|
|
145 |
|
146 |
## Dataset Description
|
147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
|
149 |
### Dataset Summary
|
150 |
|
|
|
116 |
|
117 |
# 🧨 Danish Dynaword
|
118 |
|
119 |
+
| | |
|
120 |
+
| ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
121 |
+
| **Language** | dan, dansk, Danish |
|
122 |
+
| **License** | Permissible, See the respective dataset |
|
123 |
+
| **Models** | For model trained used this data see [danish-foundation-models](https://huggingface.co/danish-foundation-models) |
|
124 |
| **Contact** | If you have question about this project please create an issue [here](https://huggingface.co/datasets/danish-foundation-models/danish-dynaword/discussions) |
|
125 |
|
126 |
|
|
|
145 |
|
146 |
## Dataset Description
|
147 |
|
148 |
+
<!-- START-DESC-STATS -->
|
149 |
+
|
150 |
+
- **Language**: dan, dansk, Danish
|
151 |
+
- **Number of samples**: 546.77K
|
152 |
+
- **Average document length (characters)**: 8461.25
|
153 |
+
|
154 |
+
<!-- END-DESC-STATS -->
|
155 |
|
156 |
### Dataset Summary
|
157 |
|
data/adl/adl.md
CHANGED
@@ -17,8 +17,9 @@ task_ids:
|
|
17 |
|
18 |
<!-- START-DESC-STATS -->
|
19 |
|
20 |
-
- **
|
21 |
-
- **
|
|
|
22 |
|
23 |
<!-- END-DESC-STATS -->
|
24 |
|
|
|
17 |
|
18 |
<!-- START-DESC-STATS -->
|
19 |
|
20 |
+
- **Language**: dan, dansk, Danish
|
21 |
+
- **Number of samples**: 498
|
22 |
+
- **Average document length (characters)**: 324932.24
|
23 |
|
24 |
<!-- END-DESC-STATS -->
|
25 |
|
data/adl/descriptive_stats.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"number_of_samples": 498, "average_document_length": 324932.2429718876, "language": "dan, dansk, Danish"}
|
data/botxt/botxt.md
CHANGED
@@ -17,8 +17,9 @@ task_ids:
|
|
17 |
|
18 |
<!-- START-DESC-STATS -->
|
19 |
|
20 |
-
- **
|
21 |
-
- **
|
|
|
22 |
|
23 |
<!-- END-DESC-STATS -->
|
24 |
|
|
|
17 |
|
18 |
<!-- START-DESC-STATS -->
|
19 |
|
20 |
+
- **Language**: dan, dansk, Danish
|
21 |
+
- **Number of samples**: 106
|
22 |
+
- **Average document length (characters)**: 18972.42
|
23 |
|
24 |
<!-- END-DESC-STATS -->
|
25 |
|
data/botxt/descriptive_stats.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"number_of_samples": 106, "average_document_length": 18972.415094339623, "language": "dan, dansk, Danish"}
|
data/dannet/dannet.md
CHANGED
@@ -17,8 +17,9 @@ task_ids:
|
|
17 |
|
18 |
<!-- START-DESC-STATS -->
|
19 |
|
20 |
-
- **
|
21 |
-
- **
|
|
|
22 |
|
23 |
<!-- END-DESC-STATS -->
|
24 |
|
|
|
17 |
|
18 |
<!-- START-DESC-STATS -->
|
19 |
|
20 |
+
- **Language**: dan, dansk, Danish
|
21 |
+
- **Number of samples**: 49.04K
|
22 |
+
- **Average document length (characters)**: 90.80
|
23 |
|
24 |
<!-- END-DESC-STATS -->
|
25 |
|
data/dannet/descriptive_stats.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"number_of_samples": 49040, "average_document_length": 90.80340538336053, "language": "dan, dansk, Danish"}
|
data/depbank/descriptive_stats.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"number_of_samples": 536, "average_document_length": 1018.8992537313433, "language": "dan, dansk, Danish"}
|
data/ep/descriptive_stats.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"number_of_samples": 4213, "average_document_length": 74063.40469973891, "language": "dan, dansk, Danish"}
|
data/ft/descriptive_stats.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"number_of_samples": 1315, "average_document_length": 266745.19163498096, "language": "dan, dansk, Danish"}
|
data/ft/ft.md
CHANGED
@@ -17,8 +17,9 @@ task_ids:
|
|
17 |
|
18 |
<!-- START-DESC-STATS -->
|
19 |
|
20 |
-
- **
|
21 |
-
- **
|
|
|
22 |
|
23 |
<!-- END-DESC-STATS -->
|
24 |
|
|
|
17 |
|
18 |
<!-- START-DESC-STATS -->
|
19 |
|
20 |
+
- **Language**: dan, dansk, Danish
|
21 |
+
- **Number of samples**: 1.31K
|
22 |
+
- **Average document length (characters)**: 266745.19
|
23 |
|
24 |
<!-- END-DESC-STATS -->
|
25 |
|
data/gutenberg/descriptive_stats.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"number_of_samples": 66, "average_document_length": 290147.9393939394, "language": "dan, dansk, Danish"}
|
data/hest/descriptive_stats.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"number_of_samples": 14391, "average_document_length": 82950.79104996179, "language": "dan, dansk, Danish"}
|
data/jvj/descriptive_stats.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"number_of_samples": 42, "average_document_length": 254893.66666666666, "language": "dan, dansk, Danish"}
|
data/naat/descriptive_stats.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"number_of_samples": 129, "average_document_length": 6832.387596899225, "language": "dan, dansk, Danish"}
|
data/naat/naat.md
CHANGED
@@ -17,8 +17,9 @@ task_ids:
|
|
17 |
|
18 |
<!-- START-DESC-STATS -->
|
19 |
|
20 |
-
- **
|
21 |
-
- **
|
|
|
22 |
|
23 |
<!-- END-DESC-STATS -->
|
24 |
|
|
|
17 |
|
18 |
<!-- START-DESC-STATS -->
|
19 |
|
20 |
+
- **Language**: dan, dansk, Danish
|
21 |
+
- **Number of samples**: 129
|
22 |
+
- **Average document length (characters)**: 6832.39
|
23 |
|
24 |
<!-- END-DESC-STATS -->
|
25 |
|
data/nordjyllandnews/descriptive_stats.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"number_of_samples": 75219, "average_document_length": 1540.2673659580691, "language": "dan, dansk, Danish"}
|
data/nordjyllandnews/nordjyllandnews.md
CHANGED
@@ -21,8 +21,9 @@ source: https://huggingface.co/datasets/alexandrainst/nordjylland-news-summariza
|
|
21 |
|
22 |
<!-- START-DESC-STATS -->
|
23 |
|
24 |
-
- **
|
25 |
-
- **
|
|
|
26 |
|
27 |
<!-- END-DESC-STATS -->
|
28 |
|
|
|
21 |
|
22 |
<!-- START-DESC-STATS -->
|
23 |
|
24 |
+
- **Language**: dan, dansk, Danish
|
25 |
+
- **Number of samples**: 75.22K
|
26 |
+
- **Average document length (characters)**: 1540.27
|
27 |
|
28 |
<!-- END-DESC-STATS -->
|
29 |
|
data/relig/descriptive_stats.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"number_of_samples": 66, "average_document_length": 53873.56060606061, "language": "dan, dansk, Danish"}
|
data/relig/relig.md
CHANGED
@@ -13,9 +13,18 @@ task_ids:
|
|
13 |
- language-modeling
|
14 |
---
|
15 |
# Dataset Card for Religious texts
|
|
|
16 |
## Dataset Description
|
17 |
-
|
18 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
## Dataset Sturcture
|
20 |
An example from the dataset looks as follows.
|
21 |
```yaml
|
|
|
13 |
- language-modeling
|
14 |
---
|
15 |
# Dataset Card for Religious texts
|
16 |
+
|
17 |
## Dataset Description
|
18 |
+
|
19 |
+
<!-- START-DESC-STATS -->
|
20 |
+
|
21 |
+
- **Language**: dan, dansk, Danish
|
22 |
+
- **Number of samples**: 66
|
23 |
+
- **Average document length (characters)**: 53873.56
|
24 |
+
|
25 |
+
<!-- END-DESC-STATS -->
|
26 |
+
|
27 |
+
|
28 |
## Dataset Sturcture
|
29 |
An example from the dataset looks as follows.
|
30 |
```yaml
|
data/retsinformationdk/descriptive_stats.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"number_of_samples": 64043, "average_document_length": 22248.525506300455, "language": "dan, dansk, Danish"}
|
data/retspraksis/descriptive_stats.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"number_of_samples": 4413, "average_document_length": 46323.66915930206, "language": "dan, dansk, Danish"}
|
data/retspraksis/retspraksis.md
CHANGED
@@ -17,8 +17,9 @@ task_ids:
|
|
17 |
|
18 |
<!-- START-DESC-STATS -->
|
19 |
|
20 |
-
- **
|
21 |
-
- **
|
|
|
22 |
|
23 |
<!-- END-DESC-STATS -->
|
24 |
|
|
|
17 |
|
18 |
<!-- START-DESC-STATS -->
|
19 |
|
20 |
+
- **Language**: dan, dansk, Danish
|
21 |
+
- **Number of samples**: 4.41K
|
22 |
+
- **Average document length (characters)**: 46323.67
|
23 |
|
24 |
<!-- END-DESC-STATS -->
|
25 |
|
data/skat/descriptive_stats.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"number_of_samples": 14716, "average_document_length": 24026.800964936123, "language": "dan, dansk, Danish"}
|
data/skat/skat.md
CHANGED
@@ -17,8 +17,9 @@ task_ids:
|
|
17 |
|
18 |
<!-- START-DESC-STATS -->
|
19 |
|
20 |
-
- **
|
21 |
-
- **
|
|
|
22 |
|
23 |
<!-- END-DESC-STATS -->
|
24 |
|
|
|
17 |
|
18 |
<!-- START-DESC-STATS -->
|
19 |
|
20 |
+
- **Language**: dan, dansk, Danish
|
21 |
+
- **Number of samples**: 14.72K
|
22 |
+
- **Average document length (characters)**: 24026.80
|
23 |
|
24 |
<!-- END-DESC-STATS -->
|
25 |
|
data/spont/descriptive_stats.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"number_of_samples": 411, "average_document_length": 9736.79805352798, "language": "dan, dansk, Danish"}
|
data/synne/descriptive_stats.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"number_of_samples": 178, "average_document_length": 785.3258426966293, "language": "dan, dansk, Danish"}
|
data/synne/synne.md
CHANGED
@@ -17,8 +17,9 @@ task_ids:
|
|
17 |
|
18 |
<!-- START-DESC-STATS -->
|
19 |
|
20 |
-
- **
|
21 |
-
- **
|
|
|
22 |
|
23 |
<!-- END-DESC-STATS -->
|
24 |
|
|
|
17 |
|
18 |
<!-- START-DESC-STATS -->
|
19 |
|
20 |
+
- **Language**: dan, dansk, Danish
|
21 |
+
- **Number of samples**: 178
|
22 |
+
- **Average document length (characters)**: 785.33
|
23 |
|
24 |
<!-- END-DESC-STATS -->
|
25 |
|
data/tv2r/descriptive_stats.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"number_of_samples": 49137, "average_document_length": 1303.3820746077295, "language": "dan, dansk, Danish"}
|
data/wiki/descriptive_stats.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"number_of_samples": 264502, "average_document_length": 1386.6366794958071, "language": "dan, dansk, Danish"}
|
data/wikibooks/descriptive_stats.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"number_of_samples": 1319, "average_document_length": 13291.027293404093, "language": "dan, dansk, Danish"}
|
data/wikisource/descriptive_stats.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"number_of_samples": 2429, "average_document_length": 6372.487855084397, "language": "dan, dansk, Danish"}
|
data/wikisource/wikisource.md
CHANGED
@@ -13,6 +13,7 @@ task_ids:
|
|
13 |
- language-modeling
|
14 |
---
|
15 |
# Dataset Card for Wikisource
|
|
|
16 |
## Dataset Description
|
17 |
|
18 |
<!-- START-DESC-STATS -->
|
@@ -26,6 +27,7 @@ task_ids:
|
|
26 |
|
27 |
## Dataset Sturcture
|
28 |
An example from the dataset looks as follows.
|
|
|
29 |
```yaml
|
30 |
{
|
31 |
'text': '<poem>
|
|
|
13 |
- language-modeling
|
14 |
---
|
15 |
# Dataset Card for Wikisource
|
16 |
+
|
17 |
## Dataset Description
|
18 |
|
19 |
<!-- START-DESC-STATS -->
|
|
|
27 |
|
28 |
## Dataset Sturcture
|
29 |
An example from the dataset looks as follows.
|
30 |
+
|
31 |
```yaml
|
32 |
{
|
33 |
'text': '<poem>
|
descriptive_stats.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"number_of_samples": 546769, "average_document_length": 8461.252984349881, "language": "dan, dansk, Danish"}
|
pyproject.toml
CHANGED
@@ -6,6 +6,7 @@ readme = "README.md"
|
|
6 |
requires-python = ">=3.13"
|
7 |
dependencies = [
|
8 |
"datasets>=3.0.0",
|
|
|
9 |
"ipykernel>=6.29.5",
|
10 |
"matplotlib>=3.10.0",
|
11 |
"numpy>=2.2.0",
|
|
|
6 |
requires-python = ">=3.13"
|
7 |
dependencies = [
|
8 |
"datasets>=3.0.0",
|
9 |
+
"gitpython>=3.1.43",
|
10 |
"ipykernel>=6.29.5",
|
11 |
"matplotlib>=3.10.0",
|
12 |
"numpy>=2.2.0",
|
scripts/git_utilities.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from pathlib import Path
|
2 |
+
|
3 |
+
from git import Repo
|
4 |
+
|
5 |
+
repo_path = Path(__file__).parent.parent
|
6 |
+
|
7 |
+
|
8 |
+
def get_current_revision(repo_path: Path = repo_path) -> str:
|
9 |
+
repo = Repo(repo_path)
|
10 |
+
commit_id = repo.head.object.hexsha
|
11 |
+
return commit_id
|
12 |
+
|
13 |
+
|
14 |
+
def get_latest_revision(path: Path, repo_path=repo_path) -> str:
|
15 |
+
repo = Repo(repo_path)
|
16 |
+
|
17 |
+
if not path.exists():
|
18 |
+
raise ValueError("path does not exist.")
|
19 |
+
|
20 |
+
last_commit_for_file = next(repo.iter_commits(paths=path, max_count=1))
|
21 |
+
return last_commit_for_file.hexsha
|
22 |
+
|
23 |
+
|
24 |
+
def check_is_ancestor(ancestor_rev: str, rev: str, repo_path=repo_path) -> bool:
|
25 |
+
repo = Repo(repo_path)
|
26 |
+
return repo.is_ancestor(repo.commit(ancestor_rev), repo.commit(rev))
|
scripts/update_descriptive_statistics.py
CHANGED
@@ -1,7 +1,14 @@
|
|
1 |
"""
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
3 |
"""
|
4 |
|
|
|
|
|
5 |
import logging
|
6 |
from dataclasses import dataclass
|
7 |
from pathlib import Path
|
@@ -10,7 +17,11 @@ from typing import Self, cast
|
|
10 |
|
11 |
from datasets import Dataset, load_dataset
|
12 |
|
13 |
-
|
|
|
|
|
|
|
|
|
14 |
|
15 |
|
16 |
def human_readable_large_int(value: int) -> str:
|
@@ -67,24 +78,108 @@ class DescriptiveStatsOverview:
|
|
67 |
stats = self.to_markdown()
|
68 |
return f"{start_md}{start_identifier}{stats}{end_identifier}{end_md}"
|
69 |
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
ds = cast(Dataset, ds)
|
76 |
desc_stats = DescriptiveStatsOverview.from_dataset(ds)
|
77 |
|
78 |
-
|
|
|
79 |
with markdown_path.open("r") as f:
|
80 |
new_markdown = desc_stats.add_to_markdown(f.read())
|
81 |
with markdown_path.open("w") as f:
|
82 |
f.write(new_markdown)
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
|
85 |
-
if __name__ == "__main__":
|
86 |
-
repo_path = Path(__file__).parent.parent
|
87 |
datasets = (repo_path / "data").glob("*")
|
88 |
-
|
89 |
for dataset_path in datasets:
|
90 |
-
update_statitics(dataset_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
"""
|
2 |
+
A simple CLI to updates descriptive statistics on all datasets.
|
3 |
+
|
4 |
+
Example use:
|
5 |
+
|
6 |
+
python update_descriptive_statistics.py --dataset wikisource
|
7 |
+
|
8 |
"""
|
9 |
|
10 |
+
import argparse
|
11 |
+
import json
|
12 |
import logging
|
13 |
from dataclasses import dataclass
|
14 |
from pathlib import Path
|
|
|
17 |
|
18 |
from datasets import Dataset, load_dataset
|
19 |
|
20 |
+
from .git_utilities import check_is_ancestor, get_current_revision, get_latest_revision
|
21 |
+
|
22 |
+
logger = logging.getLogger(__name__)
|
23 |
+
|
24 |
+
repo_path = Path(__file__).parent.parent
|
25 |
|
26 |
|
27 |
def human_readable_large_int(value: int) -> str:
|
|
|
78 |
stats = self.to_markdown()
|
79 |
return f"{start_md}{start_identifier}{stats}{end_identifier}{end_md}"
|
80 |
|
81 |
+
def to_disk(self, path: Path):
|
82 |
+
data = self.__dict__
|
83 |
+
data["revision"] = get_current_revision()
|
84 |
+
with path.with_suffix(".json").open("w") as f:
|
85 |
+
json.dump(self.__dict__, f)
|
86 |
+
|
87 |
+
|
88 |
+
def update_statitics(
|
89 |
+
dataset_path: Path,
|
90 |
+
name: str,
|
91 |
+
readme_name: None | str = None,
|
92 |
+
force: bool = False,
|
93 |
+
) -> None:
|
94 |
+
rev = get_latest_revision(dataset_path)
|
95 |
+
|
96 |
+
desc_stats_path = dataset_path / "descriptive_stats.json"
|
97 |
+
if desc_stats_path.exists() and force is False:
|
98 |
+
with desc_stats_path.open("r") as f:
|
99 |
+
last_update = json.load(f).get("revision", None)
|
100 |
+
|
101 |
+
if last_update is None:
|
102 |
+
logging.warning(f"revision is not defined in {desc_stats_path}.")
|
103 |
+
elif check_is_ancestor(ancestor_rev=last_update, rev=rev):
|
104 |
+
logging.info(
|
105 |
+
f"descriptive statistics for '{name}' is already up to date, skipping."
|
106 |
+
)
|
107 |
+
return
|
108 |
+
|
109 |
+
logger.info(f"Updating statistics for {name}")
|
110 |
+
ds = load_dataset(str(repo_path), name, split="train")
|
111 |
ds = cast(Dataset, ds)
|
112 |
desc_stats = DescriptiveStatsOverview.from_dataset(ds)
|
113 |
|
114 |
+
readme_name = f"{name}.md" if readme_name is None else readme_name
|
115 |
+
markdown_path = dataset_path / readme_name
|
116 |
with markdown_path.open("r") as f:
|
117 |
new_markdown = desc_stats.add_to_markdown(f.read())
|
118 |
with markdown_path.open("w") as f:
|
119 |
f.write(new_markdown)
|
120 |
|
121 |
+
desc_stats.to_disk(desc_stats_path)
|
122 |
+
|
123 |
+
|
124 |
+
def create_parser():
|
125 |
+
parser = argparse.ArgumentParser(
|
126 |
+
description="Calculated descriptive statistics of the datasets in tha data folder"
|
127 |
+
)
|
128 |
+
parser.add_argument(
|
129 |
+
"--dataset",
|
130 |
+
default=None,
|
131 |
+
type=str,
|
132 |
+
help="Use to specify if you only want to compute the statistics from a singular dataset.",
|
133 |
+
)
|
134 |
+
parser.add_argument(
|
135 |
+
"--logging_level",
|
136 |
+
default=20,
|
137 |
+
type=int,
|
138 |
+
help="Sets the logging level. Default to 20 (INFO), other reasonable levels are 10 (DEBUG) and 30 (WARNING).",
|
139 |
+
)
|
140 |
+
parser.add_argument(
|
141 |
+
"--force",
|
142 |
+
type=bool,
|
143 |
+
action=argparse.BooleanOptionalAction,
|
144 |
+
help="Should the statistics be forcefully recomputed. By default it checks the difference in commit ids.",
|
145 |
+
)
|
146 |
+
parser.add_argument(
|
147 |
+
"--repo_path",
|
148 |
+
default=str(repo_path),
|
149 |
+
type=str,
|
150 |
+
help="The repository where to calculate the descriptive statistics from",
|
151 |
+
)
|
152 |
+
return parser
|
153 |
+
|
154 |
+
|
155 |
+
def main(
|
156 |
+
dataset: str | None = None,
|
157 |
+
logging_level: int = 20,
|
158 |
+
force: bool = False,
|
159 |
+
repo_path: Path = repo_path,
|
160 |
+
):
|
161 |
+
logging.basicConfig(level=logging_level)
|
162 |
+
|
163 |
+
if dataset:
|
164 |
+
dataset_path = repo_path / "data" / dataset
|
165 |
+
update_statitics(repo_path, dataset_path.name, force=force)
|
166 |
+
return
|
167 |
|
|
|
|
|
168 |
datasets = (repo_path / "data").glob("*")
|
|
|
169 |
for dataset_path in datasets:
|
170 |
+
update_statitics(dataset_path, dataset_path.name, force=force)
|
171 |
+
|
172 |
+
update_statitics(repo_path, "default", "README.md", force=force)
|
173 |
+
# TODO: Only compute statistics is there has been changed in repo + add force flag
|
174 |
+
|
175 |
+
|
176 |
+
if __name__ == "__main__":
|
177 |
+
parser = create_parser()
|
178 |
+
args = parser.parse_args()
|
179 |
+
|
180 |
+
main(
|
181 |
+
args.dataset,
|
182 |
+
logging_level=args.logging_level,
|
183 |
+
force=args.force,
|
184 |
+
repo_path=args.repo_path,
|
185 |
+
)
|
tests/conftest.py
CHANGED
@@ -1,9 +1,8 @@
|
|
1 |
from pathlib import Path
|
|
|
2 |
|
3 |
import pytest
|
4 |
-
|
5 |
-
# from typing import Any
|
6 |
-
# import yaml
|
7 |
|
8 |
|
9 |
@pytest.fixture()
|
@@ -11,11 +10,11 @@ def repo_path() -> Path:
|
|
11 |
return Path(__file__).parent.parent
|
12 |
|
13 |
|
14 |
-
|
15 |
-
|
16 |
|
17 |
-
|
18 |
-
|
19 |
|
20 |
-
|
21 |
-
|
|
|
1 |
from pathlib import Path
|
2 |
+
from typing import Any
|
3 |
|
4 |
import pytest
|
5 |
+
import yaml
|
|
|
|
|
6 |
|
7 |
|
8 |
@pytest.fixture()
|
|
|
10 |
return Path(__file__).parent.parent
|
11 |
|
12 |
|
13 |
+
def readme_yaml_header(repo_path: Path) -> dict[str, Any]:
|
14 |
+
readme_path = repo_path / "README.md"
|
15 |
|
16 |
+
with readme_path.open("r") as f:
|
17 |
+
readme = f.read()
|
18 |
|
19 |
+
frontmatter = readme.split("---")[1]
|
20 |
+
return yaml.safe_load(frontmatter)
|
uv.lock
CHANGED
@@ -199,10 +199,11 @@ wheels = [
|
|
199 |
|
200 |
[[package]]
|
201 |
name = "danish-dynaword"
|
202 |
-
version = "1.0.
|
203 |
source = { virtual = "." }
|
204 |
dependencies = [
|
205 |
{ name = "datasets" },
|
|
|
206 |
{ name = "ipykernel" },
|
207 |
{ name = "matplotlib" },
|
208 |
{ name = "numpy" },
|
@@ -216,6 +217,7 @@ dependencies = [
|
|
216 |
[package.metadata]
|
217 |
requires-dist = [
|
218 |
{ name = "datasets", specifier = ">=3.0.0" },
|
|
|
219 |
{ name = "ipykernel", specifier = ">=6.29.5" },
|
220 |
{ name = "matplotlib", specifier = ">=3.10.0" },
|
221 |
{ name = "numpy", specifier = ">=2.2.0" },
|
@@ -355,6 +357,30 @@ http = [
|
|
355 |
{ name = "aiohttp" },
|
356 |
]
|
357 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
358 |
[[package]]
|
359 |
name = "huggingface-hub"
|
360 |
version = "0.26.5"
|
@@ -396,7 +422,7 @@ name = "ipykernel"
|
|
396 |
version = "6.29.5"
|
397 |
source = { registry = "https://pypi.org/simple" }
|
398 |
dependencies = [
|
399 |
-
{ name = "appnope", marker = "
|
400 |
{ name = "comm" },
|
401 |
{ name = "debugpy" },
|
402 |
{ name = "ipython" },
|
@@ -552,7 +578,7 @@ dependencies = [
|
|
552 |
{ name = "numpy" },
|
553 |
{ name = "pandas" },
|
554 |
{ name = "scipy" },
|
555 |
-
{ name = "tzdata", marker = "
|
556 |
]
|
557 |
sdist = { url = "https://files.pythonhosted.org/packages/91/c3/9f83c374314b2b42e7aec65f3bf87046415ab265f209fa8a04eb6da822ee/mizani-0.13.1.tar.gz", hash = "sha256:e3247ea12c746c8104767d7e42a2d16473173c7bc314f298d8294a58f4653353", size = 765181 }
|
558 |
wheels = [
|
@@ -1062,6 +1088,15 @@ wheels = [
|
|
1062 |
{ url = "https://files.pythonhosted.org/packages/b7/ce/149a00dd41f10bc29e5921b496af8b574d8413afcd5e30dfa0ed46c2cc5e/six-1.17.0-py2.py3-none-any.whl", hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274", size = 11050 },
|
1063 |
]
|
1064 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1065 |
[[package]]
|
1066 |
name = "stack-data"
|
1067 |
version = "0.6.3"
|
@@ -1129,7 +1164,7 @@ name = "tqdm"
|
|
1129 |
version = "4.67.1"
|
1130 |
source = { registry = "https://pypi.org/simple" }
|
1131 |
dependencies = [
|
1132 |
-
{ name = "colorama", marker = "
|
1133 |
]
|
1134 |
sdist = { url = "https://files.pythonhosted.org/packages/a8/4b/29b4ef32e036bb34e4ab51796dd745cdba7ed47ad142a9f4a1eb8e0c744d/tqdm-4.67.1.tar.gz", hash = "sha256:f8aef9c52c08c13a65f30ea34f4e5aac3fd1a34959879d7e59e63027286627f2", size = 169737 }
|
1135 |
wheels = [
|
|
|
199 |
|
200 |
[[package]]
|
201 |
name = "danish-dynaword"
|
202 |
+
version = "1.0.3"
|
203 |
source = { virtual = "." }
|
204 |
dependencies = [
|
205 |
{ name = "datasets" },
|
206 |
+
{ name = "gitpython" },
|
207 |
{ name = "ipykernel" },
|
208 |
{ name = "matplotlib" },
|
209 |
{ name = "numpy" },
|
|
|
217 |
[package.metadata]
|
218 |
requires-dist = [
|
219 |
{ name = "datasets", specifier = ">=3.0.0" },
|
220 |
+
{ name = "gitpython", specifier = ">=3.1.43" },
|
221 |
{ name = "ipykernel", specifier = ">=6.29.5" },
|
222 |
{ name = "matplotlib", specifier = ">=3.10.0" },
|
223 |
{ name = "numpy", specifier = ">=2.2.0" },
|
|
|
357 |
{ name = "aiohttp" },
|
358 |
]
|
359 |
|
360 |
+
[[package]]
|
361 |
+
name = "gitdb"
|
362 |
+
version = "4.0.11"
|
363 |
+
source = { registry = "https://pypi.org/simple" }
|
364 |
+
dependencies = [
|
365 |
+
{ name = "smmap" },
|
366 |
+
]
|
367 |
+
sdist = { url = "https://files.pythonhosted.org/packages/19/0d/bbb5b5ee188dec84647a4664f3e11b06ade2bde568dbd489d9d64adef8ed/gitdb-4.0.11.tar.gz", hash = "sha256:bf5421126136d6d0af55bc1e7c1af1c397a34f5b7bd79e776cd3e89785c2b04b", size = 394469 }
|
368 |
+
wheels = [
|
369 |
+
{ url = "https://files.pythonhosted.org/packages/fd/5b/8f0c4a5bb9fd491c277c21eff7ccae71b47d43c4446c9d0c6cff2fe8c2c4/gitdb-4.0.11-py3-none-any.whl", hash = "sha256:81a3407ddd2ee8df444cbacea00e2d038e40150acfa3001696fe0dcf1d3adfa4", size = 62721 },
|
370 |
+
]
|
371 |
+
|
372 |
+
[[package]]
|
373 |
+
name = "gitpython"
|
374 |
+
version = "3.1.43"
|
375 |
+
source = { registry = "https://pypi.org/simple" }
|
376 |
+
dependencies = [
|
377 |
+
{ name = "gitdb" },
|
378 |
+
]
|
379 |
+
sdist = { url = "https://files.pythonhosted.org/packages/b6/a1/106fd9fa2dd989b6fb36e5893961f82992cf676381707253e0bf93eb1662/GitPython-3.1.43.tar.gz", hash = "sha256:35f314a9f878467f5453cc1fee295c3e18e52f1b99f10f6cf5b1682e968a9e7c", size = 214149 }
|
380 |
+
wheels = [
|
381 |
+
{ url = "https://files.pythonhosted.org/packages/e9/bd/cc3a402a6439c15c3d4294333e13042b915bbeab54edc457c723931fed3f/GitPython-3.1.43-py3-none-any.whl", hash = "sha256:eec7ec56b92aad751f9912a73404bc02ba212a23adb2c7098ee668417051a1ff", size = 207337 },
|
382 |
+
]
|
383 |
+
|
384 |
[[package]]
|
385 |
name = "huggingface-hub"
|
386 |
version = "0.26.5"
|
|
|
422 |
version = "6.29.5"
|
423 |
source = { registry = "https://pypi.org/simple" }
|
424 |
dependencies = [
|
425 |
+
{ name = "appnope", marker = "sys_platform == 'darwin'" },
|
426 |
{ name = "comm" },
|
427 |
{ name = "debugpy" },
|
428 |
{ name = "ipython" },
|
|
|
578 |
{ name = "numpy" },
|
579 |
{ name = "pandas" },
|
580 |
{ name = "scipy" },
|
581 |
+
{ name = "tzdata", marker = "sys_platform == 'emscripten' or sys_platform == 'win32'" },
|
582 |
]
|
583 |
sdist = { url = "https://files.pythonhosted.org/packages/91/c3/9f83c374314b2b42e7aec65f3bf87046415ab265f209fa8a04eb6da822ee/mizani-0.13.1.tar.gz", hash = "sha256:e3247ea12c746c8104767d7e42a2d16473173c7bc314f298d8294a58f4653353", size = 765181 }
|
584 |
wheels = [
|
|
|
1088 |
{ url = "https://files.pythonhosted.org/packages/b7/ce/149a00dd41f10bc29e5921b496af8b574d8413afcd5e30dfa0ed46c2cc5e/six-1.17.0-py2.py3-none-any.whl", hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274", size = 11050 },
|
1089 |
]
|
1090 |
|
1091 |
+
[[package]]
|
1092 |
+
name = "smmap"
|
1093 |
+
version = "5.0.1"
|
1094 |
+
source = { registry = "https://pypi.org/simple" }
|
1095 |
+
sdist = { url = "https://files.pythonhosted.org/packages/88/04/b5bf6d21dc4041000ccba7eb17dd3055feb237e7ffc2c20d3fae3af62baa/smmap-5.0.1.tar.gz", hash = "sha256:dceeb6c0028fdb6734471eb07c0cd2aae706ccaecab45965ee83f11c8d3b1f62", size = 22291 }
|
1096 |
+
wheels = [
|
1097 |
+
{ url = "https://files.pythonhosted.org/packages/a7/a5/10f97f73544edcdef54409f1d839f6049a0d79df68adbc1ceb24d1aaca42/smmap-5.0.1-py3-none-any.whl", hash = "sha256:e6d8668fa5f93e706934a62d7b4db19c8d9eb8cf2adbb75ef1b675aa332b69da", size = 24282 },
|
1098 |
+
]
|
1099 |
+
|
1100 |
[[package]]
|
1101 |
name = "stack-data"
|
1102 |
version = "0.6.3"
|
|
|
1164 |
version = "4.67.1"
|
1165 |
source = { registry = "https://pypi.org/simple" }
|
1166 |
dependencies = [
|
1167 |
+
{ name = "colorama", marker = "sys_platform == 'win32'" },
|
1168 |
]
|
1169 |
sdist = { url = "https://files.pythonhosted.org/packages/a8/4b/29b4ef32e036bb34e4ab51796dd745cdba7ed47ad142a9f4a1eb8e0c744d/tqdm-4.67.1.tar.gz", hash = "sha256:f8aef9c52c08c13a65f30ea34f4e5aac3fd1a34959879d7e59e63027286627f2", size = 169737 }
|
1170 |
wheels = [
|