Datasets:
Tasks:
Text Generation
Formats:
parquet
Sub-tasks:
language-modeling
Languages:
Danish
Size:
1M - 10M
License:
Kenneth Enevoldsen
commited on
improves metadata
Browse files- src/dynaword/tables.py +36 -10
src/dynaword/tables.py
CHANGED
@@ -45,9 +45,15 @@ def create_dataset_readme_references():
|
|
45 |
return readme_references
|
46 |
|
47 |
|
48 |
-
def create_overview_table(
|
|
|
|
|
|
|
|
|
|
|
49 |
table = {
|
50 |
"Source": [],
|
|
|
51 |
"Description": [],
|
52 |
"Domain": [],
|
53 |
"N. Tokens": [],
|
@@ -62,22 +68,42 @@ def create_overview_table(repo_path: Path = repo_path) -> pd.DataFrame:
|
|
62 |
desc_stats = sheet.get_descritive_stats()
|
63 |
main_domain = sheet.domains[0] if sheet.domains else ""
|
64 |
|
65 |
-
table["Source"] += [f"
|
|
|
66 |
table["License"] += [f"[{sheet.license_name}]"]
|
67 |
table["Domain"] += [main_domain]
|
68 |
table["Description"] += [sheet.short_description]
|
69 |
table["N. Tokens"] += [desc_stats.number_of_tokens]
|
70 |
|
71 |
-
# total
|
72 |
-
table["Source"] += ["**Total**"]
|
73 |
-
table["Domain"] += [""]
|
74 |
-
table["License"] += [""]
|
75 |
-
table["Description"] += [""]
|
76 |
-
table["N. Tokens"] += [sum(table["N. Tokens"])]
|
77 |
-
|
78 |
df = pd.DataFrame.from_dict(table)
|
79 |
df = df.sort_values("N. Tokens", ascending=False)
|
80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
return df
|
83 |
|
|
|
45 |
return readme_references
|
46 |
|
47 |
|
48 |
+
def create_overview_table(
|
49 |
+
repo_path: Path = repo_path,
|
50 |
+
add_readable_tokens: bool = True,
|
51 |
+
add_total_row: bool = True,
|
52 |
+
add_readme_references: bool = True,
|
53 |
+
) -> pd.DataFrame:
|
54 |
table = {
|
55 |
"Source": [],
|
56 |
+
"Source with link": [],
|
57 |
"Description": [],
|
58 |
"Domain": [],
|
59 |
"N. Tokens": [],
|
|
|
68 |
desc_stats = sheet.get_descritive_stats()
|
69 |
main_domain = sheet.domains[0] if sheet.domains else ""
|
70 |
|
71 |
+
table["Source"] += [f"{dataset_path.name}"]
|
72 |
+
table["Source with link"] += [f"[{dataset_path.name}]"]
|
73 |
table["License"] += [f"[{sheet.license_name}]"]
|
74 |
table["Domain"] += [main_domain]
|
75 |
table["Description"] += [sheet.short_description]
|
76 |
table["N. Tokens"] += [desc_stats.number_of_tokens]
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
df = pd.DataFrame.from_dict(table)
|
79 |
df = df.sort_values("N. Tokens", ascending=False)
|
80 |
+
|
81 |
+
if add_total_row:
|
82 |
+
total_row = {
|
83 |
+
"Source": "**Total**",
|
84 |
+
"Source with link": "**Total**",
|
85 |
+
"Domain": "",
|
86 |
+
"License": "",
|
87 |
+
"Description": "",
|
88 |
+
"N. Tokens": sum(table["N. Tokens"]),
|
89 |
+
}
|
90 |
+
df = pd.concat(
|
91 |
+
[
|
92 |
+
df,
|
93 |
+
pd.DataFrame([total_row]),
|
94 |
+
],
|
95 |
+
ignore_index=True,
|
96 |
+
)
|
97 |
+
if add_readme_references:
|
98 |
+
# replace Source with Source with link
|
99 |
+
df["Source"] = df["Source with link"]
|
100 |
+
df = df.drop(columns=["Source with link"])
|
101 |
+
else:
|
102 |
+
# remove Source with link
|
103 |
+
df = df.drop(columns=["Source with link"])
|
104 |
+
|
105 |
+
if add_readable_tokens:
|
106 |
+
df["N. Tokens"] = df["N. Tokens"].apply(human_readable_large_int)
|
107 |
|
108 |
return df
|
109 |
|