nskwal commited on
Commit
59104b9
1 Parent(s): 28b3614

add config

Browse files
Files changed (4) hide show
  1. brwac-clean.py +62 -0
  2. brwac-clean.py.lock +0 -0
  3. dataset_infos.json +1 -0
  4. file_names.txt +12 -0
brwac-clean.py ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+
3
+ import collections
4
+ import gzip
5
+
6
+ import datasets
7
+
8
+
9
+ logger = datasets.logging.get_logger(__name__)
10
+
11
+ _BASE_DIR = "/home/diogo/extracted/brwac-clean/"
12
+ _BASE_DATA_DIR = "/home/diogo/extracted/brwac-clean/data/"
13
+
14
+
15
+ class BrwacCleanConfig(datasets.BuilderConfig):
16
+ """BRWAC-clean corpus."""
17
+
18
+ def __init__(self, **kwargs):
19
+ # Initialize the base class.
20
+ name = "brwac-clean"
21
+ description = "brwac-clean dataset"
22
+ super(BrwacCleanConfig, self).__init__(name=name, description=description, **kwargs)
23
+
24
+ # Additional attributes
25
+ self.base_data_url = _BASE_DATA_DIR
26
+
27
+
28
+ class BrwacClean(datasets.GeneratorBasedBuilder):
29
+ """BRWAC corpus."""
30
+
31
+ BUILDER_CONFIGS = [
32
+ BrwacCleanConfig(
33
+ version=datasets.Version("1.0.0"),
34
+ )
35
+ ]
36
+ BUILDER_CONFIG_CLASS = BrwacCleanConfig
37
+
38
+ def _info(self):
39
+ return datasets.DatasetInfo(
40
+ features=datasets.Features({"id": datasets.Value("int64"), "text": datasets.Value("string")}),
41
+ supervised_keys=None,
42
+ )
43
+
44
+ def _split_generators(self, dl_manager):
45
+ files = _BASE_DIR + "file_names.txt"
46
+ with open(files, encoding="utf-8") as f:
47
+ data_filenames = [line.split("\t")[0] for line in f if line]
48
+ data_urls = [self.config.base_data_url + data_filename.strip() for data_filename in data_filenames]
49
+ downloaded_files = dl_manager.download(data_urls)
50
+ return [
51
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepaths": downloaded_files}),
52
+ ]
53
+
54
+ def _generate_examples(self, filepaths):
55
+ """This function returns the examples in the raw (text) form by iterating on all the files."""
56
+ id_ = 0
57
+ for filepath in filepaths:
58
+ with gzip.open(open(filepath, "rb"), "rt", encoding="utf-8") as f:
59
+ for line in f:
60
+ feature = id_, {"id": id_, "text": line.replace("<END>", "\n").rstrip()}
61
+ yield feature
62
+ id_ += 1
brwac-clean.py.lock ADDED
File without changes
dataset_infos.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"brwac-clean": {"description": "", "citation": "", "homepage": "", "license": "", "features": {"id": {"dtype": "int64", "id": null, "_type": "Value"}, "text": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "brwac_clean", "config_name": "brwac-clean", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 7388098184, "num_examples": 3530796, "dataset_name": "brwac_clean"}}, "download_checksums": {"/home/diogo/extracted/brwac-clean/data/brwac-clean-1.txt.gz": {"num_bytes": 243939232, "checksum": "11bf33debe90b4e05514e1e0b88bba04138e17a7f83a97c7e8b5e130ea50015c"}, "/home/diogo/extracted/brwac-clean/data/brwac-clean-2.txt.gz": {"num_bytes": 190833786, "checksum": "b0c137f59f685f1415a667529e1ede3a07a0049a2264beadde46d2ecf207f432"}, "/home/diogo/extracted/brwac-clean/data/brwac-clean-3.txt.gz": {"num_bytes": 213158458, "checksum": "1655b12a5c0bd4be49328722e01fffdb3c4d29df333280282c685f549dca911b"}, "/home/diogo/extracted/brwac-clean/data/brwac-clean-4.txt.gz": {"num_bytes": 190491936, "checksum": "feef3bb4d6efaa51267f7756449f8c40a0f2bd56e3cfaafa24b5ba5b08657df5"}, "/home/diogo/extracted/brwac-clean/data/brwac-clean-5.txt.gz": {"num_bytes": 254603468, "checksum": "6b78d3864e034877ab08d01c217baa69e2af31122c0ec20e60ecce834e890018"}, "/home/diogo/extracted/brwac-clean/data/brwac-clean-6.txt.gz": {"num_bytes": 335053382, "checksum": "98d7bb6ba6430a1d1ee6a0ae306750e1e63388fd4c63161df0ebdd3cf7697789"}, "/home/diogo/extracted/brwac-clean/data/brwac-clean-7.txt.gz": {"num_bytes": 229010430, "checksum": "0b0dfcf07245e99331c6de49d04ed70849568258d1afa15ea361647e72523ce8"}, "/home/diogo/extracted/brwac-clean/data/brwac-clean-8.txt.gz": {"num_bytes": 196775422, "checksum": "b842b9a51ffa687dbb6b927220ff563f52d0d38fc0a29a104d6578c1506b0e38"}, "/home/diogo/extracted/brwac-clean/data/brwac-clean-9.txt.gz": {"num_bytes": 259196712, "checksum": "9b793ae63a43e5077ca604a5e4bc155aa0174f95b26eae0d7a589bfca5904576"}, "/home/diogo/extracted/brwac-clean/data/brwac-clean-10.txt.gz": {"num_bytes": 321435863, "checksum": "7f8c17e20fdf43a73c8d4a39df4ea7c54d0b015962f954c1bc42f5ca160d4ab5"}, "/home/diogo/extracted/brwac-clean/data/brwac-clean-11.txt.gz": {"num_bytes": 187973833, "checksum": "7677c44e950c4eeb7b2d6584b52967c557bb31ee7f571a4003c9473c5a922ea5"}, "/home/diogo/extracted/brwac-clean/data/brwac-clean-12.txt.gz": {"num_bytes": 214784795, "checksum": "29fc43db6e5af7a3841f6bf08764659453d3b95670a56edc5ab97e16906a7799"}}, "download_size": 2837257317, "post_processing_size": null, "dataset_size": 7388098184, "size_in_bytes": 10225355501}}
file_names.txt ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ brwac-clean-1.txt.gz
2
+ brwac-clean-2.txt.gz
3
+ brwac-clean-3.txt.gz
4
+ brwac-clean-4.txt.gz
5
+ brwac-clean-5.txt.gz
6
+ brwac-clean-6.txt.gz
7
+ brwac-clean-7.txt.gz
8
+ brwac-clean-8.txt.gz
9
+ brwac-clean-9.txt.gz
10
+ brwac-clean-10.txt.gz
11
+ brwac-clean-11.txt.gz
12
+ brwac-clean-12.txt.gz