CoolFace
Datasetpublic

Rijgersberg/common_corpus_nl

Common Corpus v2 NL This is a version of Common Corpus v2 filtered to keep only the rows where language is "Dutch". Common Corpus is a very large open and permissible licensed text dataset created by Pleias. Please be sure to acknowledge the creators of the original dataset when using this filtered version. Filtering Common Corpus is a collection of disparate datasets. Note that filtering the entire collection for rows where the language is "Dutch" is not the same… See the full description on the dataset page: https://huggingface.co/datasets/Rijgersberg/common_corpus_nl.

sourceHugging Faceupdated 2y agoView on Hugging Face
4likes1.4kdownloads
Dataset Card

Common Corpus v2 NL

This is a version of Common Corpus v2 filtered to keep only the rows where language is "Dutch".

Common Corpus is a very large open and permissible licensed text dataset created by Pleias. Please be sure to acknowledge the creators of the original dataset when using this filtered version.

Filtering

Common Corpus is a collection of disparate datasets. Note that filtering the entire collection for rows where the language is "Dutch" is not the same as filtering for entire datasets that are supposed to be Dutch-language. Since language classification is an automated process, there may be false positives and false negatives.

Examples are:

  • —false positives: code from StackExchange, French from French-PD-diverse are included in Common Corpus NL when they shouldn't be.
  • —false negatives: rows from Dutch-PD that were misclassified, for example as English, are not included in Common Corpus NL when they should be.

If you want to use entire datasets, you either have to look up what the source was for including it into Common Corpus, or filter Common Corpus yourself.

Usage

python
from datasets import load_dataset

# load the full dataset
dataset = load_dataset('Rijgersberg/common_corpus_nl', 'all', split='train')

# load only a specific subset
wikipedia = load_dataset('Rijgersberg/common_corpus_nl', 'Open Web-Wikipedia', split='train')

Contents

The dataset has the following content. Tokens are measured by the robbert-2023-dutch-base Dutch tokenizer on the text column only. word_count is taken directly from the word_count column of the dataset.

collectionopen_typerow_countword_counttoken_count
Dutch-PDOpen Culture198,0901,341,547,2292,453,085,804
French-PD-diverseOpen Culture5,35738,359,00975,965,219
GutenbergOpen Culture4,84444,405,78474,446,253
US-PD-BooksOpen Culture3,71423,298,10853,772,090
Multilingual-PDOpen Culture3,16422,935,49645,033,262
English-PDOpen Culture2,62218,344,86138,407,512
German-PDOpen Culture1,74412,434,46826,319,336
US-PD-NewspapersOpen Culture1,4785,297,25911,335,348
Latin-PDOpen Culture6374,406,8709,623,548
LoC-PD-BooksOpen Culture4803,384,8866,359,398
Italian-PDOpen Culture2531,767,9944,185,808
French-PD-BooksOpen Culture1951,462,3123,326,121
EuropeanaOpen Culture126751,9612,018,302
Spanish-PD-BooksOpen Culture114819,3891,831,298
French-PD-NewspapersOpen Culture117589,8991,352,344
Danish-PDOpen Culture36260,479578,291
Spanish-PD-NewspapersOpen Culture34221,839533,701
German-PD-NewspapersOpen Culture27155,979398,229
NewZealand-PD-NewspapersOpen Culture70135,552348,682
Polish-PDOpen Culture637,573135,721
Portuguese-PDOpen Culture535,66684,105
Greek-PDOpen Culture111,08423,343
BNL Newspapers (1841-1879)Open Culture426,40917,658
WikisourceOpen Culture13658
EurlexOpen Government269,340948,031,1372,104,235,522
EurovocOpen Government46,006480,170,115971,763,805
French Open DataOpen Government228,097211,210,103546,913,250
Marianne-EuropeOpen Government10,10144,308,181113,369,293
TEDEUTendersOpen Government5,1053,423,3518,123,266
USPTOOpen Government40410,0101,505,353
UN-Digital-LibraryOpen Government1995,691436,028
WTOOpen Government1155,733125,785
Court ListenerOpen Government24322,17682,334
OECDOpen Government530,89556,160
Caselaw Access ProjectOpen Government45013,34433,405
GATT_libraryOpen Government12821,112
OpenAlexOpen Science11,86776,200,223142,457,454
French-Science-PileOpen Science1,4856,197,57218,685,715
Open-Science-PileOpen Science1,1994,711,9628,011,769
German-Science-PileOpen Science9854,234,7087,488,555
Spanish-Science-PileOpen Science1631,071,8262,263,934
WikipediaOpen Web2,135,977367,689,443634,440,794
StackExchangeOpen Web270,147117,494,333464,336,069
Youtube-CommonsOpen Web1,9825,886,7728,329,426
NoneNone27291,685
total3,206,3823,791,928,7287,841,842,145

Code

In principle it is very easy to create Common Corpus NL by filtering Common Corpus using Hugging Face datasets' dataset.filter() functionality. However, Common Corpus is larger than my available disk space.

A possible solution is to process Common Corpus streaming and relying on the fact that the Dutch subset will be much, much smaller than the full dataset. The code for that solution is below. However, I was having trouble streaming the entire dataset without any connection errors along the way.

python
from datasets import load_dataset, Dataset


common_corpus = load_dataset('PleIAs/common_corpus', split='train', streaming=True)

def nl():
    for row in common_corpus:
        if row['language'] == 'Dutch':
            yield row

common_corpus_nl = Dataset.from_generator(nl)

common_corpus_nl.push_to_hub('Rijgersberg/common_corpus_nl')

Therefore I took the approach for every one of ten subfolders of Common Corpus:

  • —downloading the subfolder in a fault-tolerant way
  • —doing the filtering to Dutch rows only
  • —uploading that by itself to the Hugging Face hub
  • —deleting all the downloaded files and datasets cache files (around 1.5 TB for every subfolder)

Then finally I concatenated the ten Dutch datasets into a single one, which is the one you are looking at.

python
import shutil

from datasets import concatenate_datasets, load_dataset
from huggingface_hub import snapshot_download
from huggingface_hub.errors import LocalEntryNotFoundError
from requests import ReadTimeout


local_dir = '/path/to/downloadfolder/commoncorpus'

for i in range(1, 10+1):
    success = False
    while not success:
        try:
            # download one common corpus folder at a time to a local directory
            snapshot_download(  # will skip files that have already been downloaded
                repo_id='PleIAs/common_corpus',
                repo_type='dataset',
                allow_patterns=f'common_corpus_{i}/*',
                local_dir=local_dir
            )
            success = True
        except (LocalEntryNotFoundError, ReadTimeout) as e:
            print(e)

    subdataset = load_dataset(local_dir, split='train')
    subdataset = subdataset.filter(lambda lang: lang == 'Dutch', input_columns=['language'])

    subdataset.push_to_hub(f'Rijgersberg/common_corpus_nl_{i}')

    # remove local copies of the data to free up disk space
    shutil.rmtree(local_dir)
    shutil.rmtree('/path/to/cache/huggingface/datasets/commoncorpus')

# concatenate all (much smaller) Dutch datasets into a single dataset
common_corpus_nl = concatenate_datasets([load_dataset(f'Rijgersberg/common_corpus_nl_{i}', split='train')
                                         for i in range(1, 10+1)])
common_corpus_nl.push_to_hub('Rijgersberg/common_corpus_nl')