pkedzia commited on
Commit
d5beab9
1 Parent(s): 5c6b5fc

Upload legal-mc4-pl.py

Browse files
Files changed (1) hide show
  1. legal-mc4-pl.py +54 -0
legal-mc4-pl.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import csv
3
+ import os
4
+ import datasets
5
+
6
+ logger = datasets.logging.get_logger(__name__)
7
+
8
+ _DESCRIPTION = """
9
+ This is legal-mc4 polish dataset. This dump is converted from parquet format.
10
+ """
11
+ _SPLITS = ["corpus"]
12
+
13
+ _URLs = {
14
+ "corpus": "corpus.jsonl.gz"
15
+ }
16
+
17
+ class PolishLegalMC4(datasets.GeneratorBasedBuilder):
18
+ BUILDER_CONFIGS = [
19
+ datasets.BuilderConfig(
20
+ name="corpus",
21
+ description=_DESCRIPTION
22
+ )
23
+ ]
24
+
25
+ def _info(self):
26
+ return datasets.DatasetInfo(
27
+ description=_DESCRIPTION,
28
+ features=datasets.Features({
29
+ "url": datasets.Value("string"),
30
+ "timestamp": datasets.Value("string"),
31
+ "matches": datasets.Value("list"),
32
+ "text": datasets.Value("string"),
33
+ }),
34
+ supervised_keys=None,
35
+ )
36
+
37
+ def _split_generators(self, dl_manager):
38
+ my_urls = _URLs[self.config.name]
39
+ data_dir = dl_manager.download_and_extract(my_urls)
40
+
41
+ return [
42
+ datasets.SplitGenerator(
43
+ name=self.config.name,
44
+ gen_kwargs={"filepath": data_dir},
45
+ ),
46
+ ]
47
+
48
+ def _generate_examples(self, filepath):
49
+ with open(filepath, encoding="utf-8") as f:
50
+ texts = f.readlines()
51
+
52
+ for i, text in enumerate(texts):
53
+ text = json.loads(text)
54
+ yield i, text