Datasets:

Modalities:
Image
Text
Formats:
parquet
Languages:
Danish
ArXiv:
DOI:
Libraries:
Datasets
Dask
License:
kris927b commited on
Commit
4eb041a
·
1 Parent(s): dd36adf

Adding domain table

Browse files
README.md CHANGED
@@ -322,6 +322,61 @@ This data generally contains no annotation besides the metadata attached to each
322
 
323
  Below follows a brief overview of the sources in the corpus along with their individual license.
324
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
325
  <!-- START-MAIN TABLE -->
326
  | Source | Description | Domain | N. Tokens | License |
327
  |:---------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-------------|:------------|:-----------------------|
@@ -412,6 +467,7 @@ Below follows a brief overview of the sources in the corpus along with their ind
412
  [Danish Copyright Law]: ./data/domsdatabasen/domsdatabasen.md#license-information
413
  <!-- END-MAIN TABLE -->
414
 
 
415
 
416
  You can learn more about each dataset by pressing the link in the first column.
417
 
 
322
 
323
  Below follows a brief overview of the sources in the corpus along with their individual license.
324
 
325
+ <!-- START-DOMAIN TABLE -->
326
+ | Domain | N. Tokens | Source with link |
327
+ |:-------------|:------------|:----------------------------------------------------------------------------------------|
328
+ | Legal | 2.23B | [cellar], [eur-lex-sum-da], [fm-udgivelser], [retsinformationdk], [skat], [retspraksis] |
329
+ | Books | 722.00M | [ncc_books], [memo], [adl], [wikibooks], [jvj], [gutenberg], [relig] |
330
+ | Conversation | 497.09M | [danske-taler], [opensubtitles], [ep], [ft], [spont], [naat] |
331
+ | Social Media | 389.32M | [hest] |
332
+ | Other | 340.59M | [ncc_parliament], [dannet], [depbank], [synne] |
333
+ | Web | 295.87M | [ai-aktindsigt], [ncc_maalfrid], [miljoeportalen] |
334
+ | Encyclopedic | 127.35M | [wikisource], [wiki] |
335
+ | News | 60.63M | [ncc_newspaper], [tv2r], [nordjyllandnews] |
336
+ | Medical | 27.07M | [health_hovedstaden] |
337
+ | Readaloud | 7.30M | [nota] |
338
+ | Dialect | 847.97K | [botxt] |
339
+ | **Total** | 4.70B | |
340
+
341
+ [ai-aktindsigt]: data/ai-aktindsigt/ai-aktindsigt.md
342
+ [cellar]: data/cellar/cellar.md
343
+ [danske-taler]: data/danske-taler/danske-taler.md
344
+ [ncc_books]: data/ncc_books/ncc_books.md
345
+ [ncc_newspaper]: data/ncc_newspaper/ncc_newspaper.md
346
+ [ncc_maalfrid]: data/ncc_maalfrid/ncc_maalfrid.md
347
+ [ncc_parliament]: data/ncc_parliament/ncc_parliament.md
348
+ [eur-lex-sum-da]: data/eur-lex-sum-da/eur-lex-sum-da.md
349
+ [miljoeportalen]: data/miljoeportalen/miljoeportalen.md
350
+ [fm-udgivelser]: data/fm-udgivelser/fm-udgivelser.md
351
+ [memo]: data/memo/memo.md
352
+ [opensubtitles]: data/opensubtitles/opensubtitles.md
353
+ [retsinformationdk]: data/retsinformationdk/retsinformationdk.md
354
+ [ep]: data/ep/ep.md
355
+ [ft]: data/ft/ft.md
356
+ [wikisource]: data/wikisource/wikisource.md
357
+ [spont]: data/spont/spont.md
358
+ [tv2r]: data/tv2r/tv2r.md
359
+ [adl]: data/adl/adl.md
360
+ [hest]: data/hest/hest.md
361
+ [skat]: data/skat/skat.md
362
+ [dannet]: data/dannet/dannet.md
363
+ [retspraksis]: data/retspraksis/retspraksis.md
364
+ [wikibooks]: data/wikibooks/wikibooks.md
365
+ [jvj]: data/jvj/jvj.md
366
+ [gutenberg]: data/gutenberg/gutenberg.md
367
+ [botxt]: data/botxt/botxt.md
368
+ [depbank]: data/depbank/depbank.md
369
+ [naat]: data/naat/naat.md
370
+ [synne]: data/synne/synne.md
371
+ [wiki]: data/wiki/wiki.md
372
+ [nordjyllandnews]: data/nordjyllandnews/nordjyllandnews.md
373
+ [relig]: data/relig/relig.md
374
+ [nota]: data/nota/nota.md
375
+ [health_hovedstaden]: data/health_hovedstaden/health_hovedstaden.md
376
+ <!-- END-DOMAIN TABLE -->
377
+
378
+ <details>
379
+
380
  <!-- START-MAIN TABLE -->
381
  | Source | Description | Domain | N. Tokens | License |
382
  |:---------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-------------|:------------|:-----------------------|
 
467
  [Danish Copyright Law]: ./data/domsdatabasen/domsdatabasen.md#license-information
468
  <!-- END-MAIN TABLE -->
469
 
470
+ </details>
471
 
472
  You can learn more about each dataset by pressing the link in the first column.
473
 
src/dynaword/tables.py CHANGED
@@ -108,6 +108,62 @@ def create_overview_table(
108
  return df
109
 
110
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  def create_overview_table_str(repo_path: Path = repo_path) -> str:
112
  main_table = create_overview_table(repo_path)
113
  readme_references = create_dataset_readme_references()
 
108
  return df
109
 
110
 
111
+ def create_domain_table(
112
+ repo_path: Path = repo_path,
113
+ add_readable_tokens: bool = True,
114
+ add_total_row: bool = True,
115
+ ) -> pd.DataFrame:
116
+ table = {
117
+ "Source with link": [],
118
+ "Domain": [],
119
+ "N. Tokens": [],
120
+ }
121
+
122
+ for dataset in _datasets:
123
+ dataset_path = repo_path / "data" / dataset
124
+ readme_path = dataset_path / f"{dataset_path.name}.md"
125
+
126
+ sheet = DataSheet.load_from_path(readme_path)
127
+ desc_stats = sheet.get_descritive_stats()
128
+ main_domain = sheet.domains[0] if sheet.domains else ""
129
+
130
+ table["Source with link"] += [f"[{dataset_path.name}]"]
131
+ table["Domain"] += [main_domain]
132
+ table["N. Tokens"] += [desc_stats.number_of_tokens]
133
+
134
+ if add_total_row:
135
+ table["Source with link"] += [""]
136
+ table["Domain"] += ["**Total**"]
137
+ table["N. Tokens"] += [sum(table["N. Tokens"])]
138
+
139
+ df = pd.DataFrame.from_dict(table)
140
+
141
+ df = df.groupby("Domain").agg(
142
+ {"Source with link": lambda x: ", ".join(x), "N. Tokens": sum}
143
+ )
144
+
145
+ df = df.sort_values("N. Tokens", ascending=False)
146
+
147
+ df.index.name = "Domain"
148
+ df = df.reset_index()
149
+
150
+ # Trick the Total row to be at the bottom.
151
+ new_index = list(df.index.drop(0)) + [0]
152
+ df = df.reindex(new_index)
153
+
154
+ if add_readable_tokens:
155
+ df["N. Tokens"] = df["N. Tokens"].apply(human_readable_large_int)
156
+
157
+ return df
158
+
159
+
160
+ def create_domain_table_str(repo_path: Path = repo_path) -> str:
161
+ table = create_domain_table(repo_path)
162
+ readme_references = create_dataset_readme_references()
163
+ package = f"{table.to_markdown(index=False)}\n\n{readme_references}\n\n"
164
+ return package
165
+
166
+
167
  def create_overview_table_str(repo_path: Path = repo_path) -> str:
168
  main_table = create_overview_table(repo_path)
169
  readme_references = create_dataset_readme_references()
src/dynaword/update_descriptive_statistics.py CHANGED
@@ -24,7 +24,11 @@ from dynaword.git_utilities import (
24
  )
25
  from dynaword.paths import repo_path
26
  from dynaword.plot_tokens_over_time import create_tokens_over_time_plot
27
- from dynaword.tables import create_overview_table, create_overview_table_str
 
 
 
 
28
 
29
  logger = logging.getLogger(__name__)
30
 
@@ -104,8 +108,11 @@ def update_dataset(
104
 
105
  if dataset_name == "default":
106
  logger.info("Updating Overview table")
107
- package = create_overview_table_str()
108
- sheet.body = sheet.replace_tag(package=package, tag="MAIN TABLE")
 
 
 
109
  create_domain_distribution_plot()
110
  create_tokens_over_time_plot()
111
 
 
24
  )
25
  from dynaword.paths import repo_path
26
  from dynaword.plot_tokens_over_time import create_tokens_over_time_plot
27
+ from dynaword.tables import (
28
+ create_domain_table_str,
29
+ create_overview_table,
30
+ create_overview_table_str,
31
+ )
32
 
33
  logger = logging.getLogger(__name__)
34
 
 
108
 
109
  if dataset_name == "default":
110
  logger.info("Updating Overview table")
111
+ overview_table = create_overview_table_str()
112
+ sheet.body = sheet.replace_tag(package=overview_table, tag="MAIN TABLE")
113
+ logger.info("Updating domain table")
114
+ domain_table = create_domain_table_str()
115
+ sheet.body = sheet.replace_tag(package=domain_table, tag="DOMAIN TABLE")
116
  create_domain_distribution_plot()
117
  create_tokens_over_time_plot()
118