Saied Alimoradi commited on
Commit
3973f61
1 Parent(s): 5f97a43

adding script and sample data

Browse files
Files changed (3) hide show
  1. persian_blog_V2.py +58 -0
  2. sample_test.zip +0 -0
  3. sample_train.zip +0 -0
persian_blog_V2.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datasets
2
+ import csv
3
+ import os
4
+ import sys
5
+ csv.field_size_limit(sys.maxsize)
6
+
7
+ _DESCRIPTION = """persian_blog is a dataset consist of 400K blog posts from various websites and has types of tones.
8
+ this dataset can be used in different NLG tasks and as a show-case it's is used in training reformer-persian."""
9
+ _PROJECT_URL = """"""
10
+
11
+
12
+ _CITATION = """
13
+ https://saied71.github.io/RohanAiLab/,
14
+ author={Saied Alimoradi},
15
+ year={2021}
16
+ }
17
+ """
18
+
19
+ train = "sample_train.zip"
20
+ test = "sample_test.zip"
21
+
22
+ class persian_blog_V2(datasets.GeneratorBasedBuilder):
23
+
24
+ def _info(self):
25
+ return datasets.DatasetInfo(
26
+ description=_DESCRIPTION,
27
+ features=datasets.Features(
28
+ {
29
+ "text": datasets.Value("string")
30
+ }
31
+ ),
32
+ homepage=_PROJECT_URL,
33
+ citation=_CITATION,
34
+ )
35
+
36
+
37
+
38
+ def _split_generators(self, dl_manager):
39
+ """Returns SplitGenerators."""
40
+ dl_train = dl_manager.download_and_extract(train)
41
+ dl_test = dl_manager.download_and_extract(valid)
42
+ train_dir = os.path.join(dl_train, "sample_train.zip")
43
+ test_dir = os.path.join(dl_train, "sample_test.zip")
44
+ return [
45
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_dir}),
46
+ datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": test_dir}),
47
+ ]
48
+
49
+ def _generate_examples(self, filepath):
50
+ """Yields examples."""
51
+ with open(filepath, encoding="utf-8") as f:
52
+ reader = csv.reader(f)
53
+ for id_, row in enumerate(reader):
54
+ if id_ == 0:
55
+ continue
56
+ yield id_, {
57
+ "text": row[0]
58
+ }
sample_test.zip ADDED
Binary file (17.7 kB). View file
 
sample_train.zip ADDED
Binary file (254 kB). View file