arubenruben commited on
Commit
498a422
1 Parent(s): 7a9fdf2

Add Loading Script

Browse files
README.md CHANGED
@@ -1,5 +1,622 @@
1
  ---
2
  license: mit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
4
 
5
 
 
1
  ---
2
  license: mit
3
+ dataset_info:
4
+ - config_name: algebra__linear_1d
5
+ features:
6
+ - name: question
7
+ dtype: string
8
+ - name: answer
9
+ dtype: string
10
+ splits:
11
+ - name: train
12
+ - name: test
13
+ download_size: 98096
14
+ dataset_size: 0
15
+ - config_name: algebra__linear_1d_composed
16
+ features:
17
+ - name: question
18
+ dtype: string
19
+ - name: answer
20
+ dtype: string
21
+ splits:
22
+ - name: train
23
+ - name: test
24
+ download_size: 98096
25
+ dataset_size: 0
26
+ - config_name: algebra__linear_2d
27
+ features:
28
+ - name: question
29
+ dtype: string
30
+ - name: answer
31
+ dtype: string
32
+ splits:
33
+ - name: train
34
+ - name: test
35
+ download_size: 98096
36
+ dataset_size: 0
37
+ - config_name: algebra__linear_2d_composed
38
+ features:
39
+ - name: question
40
+ dtype: string
41
+ - name: answer
42
+ dtype: string
43
+ splits:
44
+ - name: train
45
+ - name: test
46
+ download_size: 98096
47
+ dataset_size: 0
48
+ - config_name: algebra__polynomial_roots
49
+ features:
50
+ - name: question
51
+ dtype: string
52
+ - name: answer
53
+ dtype: string
54
+ splits:
55
+ - name: train
56
+ - name: test
57
+ download_size: 98096
58
+ dataset_size: 0
59
+ - config_name: algebra__polynomial_roots_composed
60
+ features:
61
+ - name: question
62
+ dtype: string
63
+ - name: answer
64
+ dtype: string
65
+ splits:
66
+ - name: train
67
+ - name: test
68
+ download_size: 98096
69
+ dataset_size: 0
70
+ - config_name: algebra__sequence_next_term
71
+ features:
72
+ - name: question
73
+ dtype: string
74
+ - name: answer
75
+ dtype: string
76
+ splits:
77
+ - name: train
78
+ - name: test
79
+ download_size: 98096
80
+ dataset_size: 0
81
+ - config_name: algebra__sequence_nth_term
82
+ features:
83
+ - name: question
84
+ dtype: string
85
+ - name: answer
86
+ dtype: string
87
+ splits:
88
+ - name: train
89
+ - name: test
90
+ download_size: 98096
91
+ dataset_size: 0
92
+ - config_name: arithmetic__add_or_sub
93
+ features:
94
+ - name: question
95
+ dtype: string
96
+ - name: answer
97
+ dtype: string
98
+ splits:
99
+ - name: train
100
+ - name: test
101
+ download_size: 98096
102
+ dataset_size: 0
103
+ - config_name: arithmetic__add_or_sub_in_base
104
+ features:
105
+ - name: question
106
+ dtype: string
107
+ - name: answer
108
+ dtype: string
109
+ splits:
110
+ - name: train
111
+ - name: test
112
+ download_size: 98096
113
+ dataset_size: 0
114
+ - config_name: arithmetic__add_sub_multiple
115
+ features:
116
+ - name: question
117
+ dtype: string
118
+ - name: answer
119
+ dtype: string
120
+ splits:
121
+ - name: train
122
+ - name: test
123
+ download_size: 98096
124
+ dataset_size: 0
125
+ - config_name: arithmetic__div
126
+ features:
127
+ - name: question
128
+ dtype: string
129
+ - name: answer
130
+ dtype: string
131
+ splits:
132
+ - name: train
133
+ - name: test
134
+ download_size: 98096
135
+ dataset_size: 0
136
+ - config_name: arithmetic__mixed
137
+ features:
138
+ - name: question
139
+ dtype: string
140
+ - name: answer
141
+ dtype: string
142
+ splits:
143
+ - name: train
144
+ - name: test
145
+ download_size: 98096
146
+ dataset_size: 0
147
+ - config_name: arithmetic__mul
148
+ features:
149
+ - name: question
150
+ dtype: string
151
+ - name: answer
152
+ dtype: string
153
+ splits:
154
+ - name: train
155
+ - name: test
156
+ download_size: 98096
157
+ dataset_size: 0
158
+ - config_name: arithmetic__mul_div_multiple
159
+ features:
160
+ - name: question
161
+ dtype: string
162
+ - name: answer
163
+ dtype: string
164
+ splits:
165
+ - name: train
166
+ - name: test
167
+ download_size: 98096
168
+ dataset_size: 0
169
+ - config_name: arithmetic__nearest_integer_root
170
+ features:
171
+ - name: question
172
+ dtype: string
173
+ - name: answer
174
+ dtype: string
175
+ splits:
176
+ - name: train
177
+ - name: test
178
+ download_size: 98096
179
+ dataset_size: 0
180
+ - config_name: arithmetic__simplify_surd
181
+ features:
182
+ - name: question
183
+ dtype: string
184
+ - name: answer
185
+ dtype: string
186
+ splits:
187
+ - name: train
188
+ - name: test
189
+ download_size: 98096
190
+ dataset_size: 0
191
+ - config_name: calculus__differentiate
192
+ features:
193
+ - name: question
194
+ dtype: string
195
+ - name: answer
196
+ dtype: string
197
+ splits:
198
+ - name: train
199
+ - name: test
200
+ download_size: 98096
201
+ dataset_size: 0
202
+ - config_name: calculus__differentiate_composed
203
+ features:
204
+ - name: question
205
+ dtype: string
206
+ - name: answer
207
+ dtype: string
208
+ splits:
209
+ - name: train
210
+ - name: test
211
+ download_size: 98096
212
+ dataset_size: 0
213
+ - config_name: comparison__closest
214
+ features:
215
+ - name: question
216
+ dtype: string
217
+ - name: answer
218
+ dtype: string
219
+ splits:
220
+ - name: train
221
+ - name: test
222
+ download_size: 98096
223
+ dataset_size: 0
224
+ - config_name: comparison__closest_composed
225
+ features:
226
+ - name: question
227
+ dtype: string
228
+ - name: answer
229
+ dtype: string
230
+ splits:
231
+ - name: train
232
+ - name: test
233
+ download_size: 98096
234
+ dataset_size: 0
235
+ - config_name: comparison__kth_biggest
236
+ features:
237
+ - name: question
238
+ dtype: string
239
+ - name: answer
240
+ dtype: string
241
+ splits:
242
+ - name: train
243
+ - name: test
244
+ download_size: 98096
245
+ dataset_size: 0
246
+ - config_name: comparison__kth_biggest_composed
247
+ features:
248
+ - name: question
249
+ dtype: string
250
+ - name: answer
251
+ dtype: string
252
+ splits:
253
+ - name: train
254
+ - name: test
255
+ download_size: 98096
256
+ dataset_size: 0
257
+ - config_name: comparison__pair
258
+ features:
259
+ - name: question
260
+ dtype: string
261
+ - name: answer
262
+ dtype: string
263
+ splits:
264
+ - name: train
265
+ - name: test
266
+ download_size: 98096
267
+ dataset_size: 0
268
+ - config_name: comparison__pair_composed
269
+ features:
270
+ - name: question
271
+ dtype: string
272
+ - name: answer
273
+ dtype: string
274
+ splits:
275
+ - name: train
276
+ - name: test
277
+ download_size: 98096
278
+ dataset_size: 0
279
+ - config_name: comparison__sort
280
+ features:
281
+ - name: question
282
+ dtype: string
283
+ - name: answer
284
+ dtype: string
285
+ splits:
286
+ - name: train
287
+ - name: test
288
+ download_size: 98096
289
+ dataset_size: 0
290
+ - config_name: comparison__sort_composed
291
+ features:
292
+ - name: question
293
+ dtype: string
294
+ - name: answer
295
+ dtype: string
296
+ splits:
297
+ - name: train
298
+ - name: test
299
+ download_size: 98096
300
+ dataset_size: 0
301
+ - config_name: measurement__conversion
302
+ features:
303
+ - name: question
304
+ dtype: string
305
+ - name: answer
306
+ dtype: string
307
+ splits:
308
+ - name: train
309
+ - name: test
310
+ download_size: 98096
311
+ dataset_size: 0
312
+ - config_name: measurement__time
313
+ features:
314
+ - name: question
315
+ dtype: string
316
+ - name: answer
317
+ dtype: string
318
+ splits:
319
+ - name: train
320
+ - name: test
321
+ download_size: 98096
322
+ dataset_size: 0
323
+ - config_name: numbers__base_conversion
324
+ features:
325
+ - name: question
326
+ dtype: string
327
+ - name: answer
328
+ dtype: string
329
+ splits:
330
+ - name: train
331
+ - name: test
332
+ download_size: 98096
333
+ dataset_size: 0
334
+ - config_name: numbers__div_remainder
335
+ features:
336
+ - name: question
337
+ dtype: string
338
+ - name: answer
339
+ dtype: string
340
+ splits:
341
+ - name: train
342
+ - name: test
343
+ download_size: 98096
344
+ dataset_size: 0
345
+ - config_name: numbers__div_remainder_composed
346
+ features:
347
+ - name: question
348
+ dtype: string
349
+ - name: answer
350
+ dtype: string
351
+ splits:
352
+ - name: train
353
+ - name: test
354
+ download_size: 98096
355
+ dataset_size: 0
356
+ - config_name: numbers__gcd
357
+ features:
358
+ - name: question
359
+ dtype: string
360
+ - name: answer
361
+ dtype: string
362
+ splits:
363
+ - name: train
364
+ - name: test
365
+ download_size: 98096
366
+ dataset_size: 0
367
+ - config_name: numbers__gcd_composed
368
+ features:
369
+ - name: question
370
+ dtype: string
371
+ - name: answer
372
+ dtype: string
373
+ splits:
374
+ - name: train
375
+ - name: test
376
+ download_size: 98096
377
+ dataset_size: 0
378
+ - config_name: numbers__is_factor
379
+ features:
380
+ - name: question
381
+ dtype: string
382
+ - name: answer
383
+ dtype: string
384
+ splits:
385
+ - name: train
386
+ - name: test
387
+ download_size: 98096
388
+ dataset_size: 0
389
+ - config_name: numbers__is_factor_composed
390
+ features:
391
+ - name: question
392
+ dtype: string
393
+ - name: answer
394
+ dtype: string
395
+ splits:
396
+ - name: train
397
+ - name: test
398
+ download_size: 98096
399
+ dataset_size: 0
400
+ - config_name: numbers__is_prime
401
+ features:
402
+ - name: question
403
+ dtype: string
404
+ - name: answer
405
+ dtype: string
406
+ splits:
407
+ - name: train
408
+ - name: test
409
+ download_size: 98096
410
+ dataset_size: 0
411
+ - config_name: numbers__is_prime_composed
412
+ features:
413
+ - name: question
414
+ dtype: string
415
+ - name: answer
416
+ dtype: string
417
+ splits:
418
+ - name: train
419
+ - name: test
420
+ download_size: 98096
421
+ dataset_size: 0
422
+ - config_name: numbers__lcm
423
+ features:
424
+ - name: question
425
+ dtype: string
426
+ - name: answer
427
+ dtype: string
428
+ splits:
429
+ - name: train
430
+ - name: test
431
+ download_size: 98096
432
+ dataset_size: 0
433
+ - config_name: numbers__lcm_composed
434
+ features:
435
+ - name: question
436
+ dtype: string
437
+ - name: answer
438
+ dtype: string
439
+ splits:
440
+ - name: train
441
+ - name: test
442
+ download_size: 98096
443
+ dataset_size: 0
444
+ - config_name: numbers__list_prime_factors
445
+ features:
446
+ - name: question
447
+ dtype: string
448
+ - name: answer
449
+ dtype: string
450
+ splits:
451
+ - name: train
452
+ - name: test
453
+ download_size: 98096
454
+ dataset_size: 0
455
+ - config_name: numbers__list_prime_factors_composed
456
+ features:
457
+ - name: question
458
+ dtype: string
459
+ - name: answer
460
+ dtype: string
461
+ splits:
462
+ - name: train
463
+ - name: test
464
+ download_size: 98096
465
+ dataset_size: 0
466
+ - config_name: numbers__place_value
467
+ features:
468
+ - name: question
469
+ dtype: string
470
+ - name: answer
471
+ dtype: string
472
+ splits:
473
+ - name: train
474
+ - name: test
475
+ download_size: 98096
476
+ dataset_size: 0
477
+ - config_name: numbers__place_value_composed
478
+ features:
479
+ - name: question
480
+ dtype: string
481
+ - name: answer
482
+ dtype: string
483
+ splits:
484
+ - name: train
485
+ - name: test
486
+ download_size: 98096
487
+ dataset_size: 0
488
+ - config_name: numbers__round_number
489
+ features:
490
+ - name: question
491
+ dtype: string
492
+ - name: answer
493
+ dtype: string
494
+ splits:
495
+ - name: train
496
+ - name: test
497
+ download_size: 98096
498
+ dataset_size: 0
499
+ - config_name: numbers__round_number_composed
500
+ features:
501
+ - name: question
502
+ dtype: string
503
+ - name: answer
504
+ dtype: string
505
+ splits:
506
+ - name: train
507
+ - name: test
508
+ download_size: 98096
509
+ dataset_size: 0
510
+ - config_name: polynomials__add
511
+ features:
512
+ - name: question
513
+ dtype: string
514
+ - name: answer
515
+ dtype: string
516
+ splits:
517
+ - name: train
518
+ - name: test
519
+ download_size: 98096
520
+ dataset_size: 0
521
+ - config_name: polynomials__coefficient_named
522
+ features:
523
+ - name: question
524
+ dtype: string
525
+ - name: answer
526
+ dtype: string
527
+ splits:
528
+ - name: train
529
+ - name: test
530
+ download_size: 98096
531
+ dataset_size: 0
532
+ - config_name: polynomials__collect
533
+ features:
534
+ - name: question
535
+ dtype: string
536
+ - name: answer
537
+ dtype: string
538
+ splits:
539
+ - name: train
540
+ - name: test
541
+ download_size: 98096
542
+ dataset_size: 0
543
+ - config_name: polynomials__compose
544
+ features:
545
+ - name: question
546
+ dtype: string
547
+ - name: answer
548
+ dtype: string
549
+ splits:
550
+ - name: train
551
+ - name: test
552
+ download_size: 98096
553
+ dataset_size: 0
554
+ - config_name: polynomials__evaluate
555
+ features:
556
+ - name: question
557
+ dtype: string
558
+ - name: answer
559
+ dtype: string
560
+ splits:
561
+ - name: train
562
+ - name: test
563
+ download_size: 98096
564
+ dataset_size: 0
565
+ - config_name: polynomials__evaluate_composed
566
+ features:
567
+ - name: question
568
+ dtype: string
569
+ - name: answer
570
+ dtype: string
571
+ splits:
572
+ - name: train
573
+ - name: test
574
+ download_size: 98096
575
+ dataset_size: 0
576
+ - config_name: polynomials__expand
577
+ features:
578
+ - name: question
579
+ dtype: string
580
+ - name: answer
581
+ dtype: string
582
+ splits:
583
+ - name: train
584
+ - name: test
585
+ download_size: 98096
586
+ dataset_size: 0
587
+ - config_name: polynomials__simplify_power
588
+ features:
589
+ - name: question
590
+ dtype: string
591
+ - name: answer
592
+ dtype: string
593
+ splits:
594
+ - name: train
595
+ - name: test
596
+ download_size: 98096
597
+ dataset_size: 0
598
+ - config_name: probability__swr_p_level_set
599
+ features:
600
+ - name: question
601
+ dtype: string
602
+ - name: answer
603
+ dtype: string
604
+ splits:
605
+ - name: train
606
+ - name: test
607
+ download_size: 98096
608
+ dataset_size: 0
609
+ - config_name: probability__swr_p_sequence
610
+ features:
611
+ - name: question
612
+ dtype: string
613
+ - name: answer
614
+ dtype: string
615
+ splits:
616
+ - name: train
617
+ - name: test
618
+ download_size: 98096
619
+ dataset_size: 0
620
  ---
621
 
622
 
mathematics_dataset/mathematics_dataset/ds.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a3e513877e85246627c135bcc6d0aa35ee84132cde51b3ad6f32b13517057cc4
3
+ size 98096
portuguese-math-dataset.py ADDED
@@ -0,0 +1,276 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2020 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ # Lint as: python3
17
+ """Mathematics database."""
18
+
19
+ import datasets
20
+ import os
21
+
22
+
23
+ logger = datasets.logging.get_logger(__name__)
24
+
25
+
26
+ _CITATION = """
27
+ @article{2019arXiv,
28
+ author = {Saxton, Grefenstette, Hill, Kohli},
29
+ title = {Analysing Mathematical Reasoning Abilities of Neural Models},
30
+ year = {2019},
31
+ journal = {arXiv:1904.01557}
32
+ }
33
+ """
34
+
35
+ _DESCRIPTION = """
36
+ Mathematics database.
37
+
38
+ This dataset code generates mathematical question and answer pairs,
39
+ from a range of question types at roughly school-level difficulty.
40
+ This is designed to test the mathematical learning and algebraic
41
+ reasoning skills of learning models.
42
+
43
+ Original paper: Analysing Mathematical Reasoning Abilities of Neural Models
44
+ (Saxton, Grefenstette, Hill, Kohli).
45
+
46
+ Example usage:
47
+ train_examples, val_examples = datasets.load_dataset(
48
+ 'math_dataset/arithmetic__mul',
49
+ split=['train', 'test'],
50
+ as_supervised=True)
51
+ """
52
+
53
+ _DATA_URL = os.path.join('mathematics_dataset', 'mathematics_dataset', 'ds.zip')
54
+
55
+ _TRAIN_CATEGORY = [
56
+ "train-easy",
57
+ "train-medium",
58
+ "train-hard",
59
+ ]
60
+
61
+ _INTERPOLATE_CATEGORY = [
62
+ "interpolate",
63
+ ]
64
+
65
+ _MODULES = [
66
+ # extrapolate
67
+ "measurement__conversion",
68
+ # interpolate
69
+ "algebra__linear_1d",
70
+ "algebra__linear_1d_composed",
71
+ "algebra__linear_2d",
72
+ "algebra__linear_2d_composed",
73
+ "algebra__polynomial_roots",
74
+ "algebra__polynomial_roots_composed",
75
+ "algebra__sequence_next_term",
76
+ "algebra__sequence_nth_term",
77
+ "arithmetic__add_or_sub",
78
+ "arithmetic__add_or_sub_in_base",
79
+ "arithmetic__add_sub_multiple",
80
+ "arithmetic__div",
81
+ "arithmetic__mixed",
82
+ "arithmetic__mul",
83
+ "arithmetic__mul_div_multiple",
84
+ "arithmetic__nearest_integer_root",
85
+ "arithmetic__simplify_surd",
86
+ "calculus__differentiate",
87
+ "calculus__differentiate_composed",
88
+ "comparison__closest",
89
+ "comparison__closest_composed",
90
+ "comparison__kth_biggest",
91
+ "comparison__kth_biggest_composed",
92
+ "comparison__pair",
93
+ "comparison__pair_composed",
94
+ "comparison__sort",
95
+ "comparison__sort_composed",
96
+ "measurement__conversion",
97
+ "measurement__time",
98
+ "numbers__base_conversion",
99
+ "numbers__div_remainder",
100
+ "numbers__div_remainder_composed",
101
+ "numbers__gcd",
102
+ "numbers__gcd_composed",
103
+ "numbers__is_factor",
104
+ "numbers__is_factor_composed",
105
+ "numbers__is_prime",
106
+ "numbers__is_prime_composed",
107
+ "numbers__lcm",
108
+ "numbers__lcm_composed",
109
+ "numbers__list_prime_factors",
110
+ "numbers__list_prime_factors_composed",
111
+ "numbers__place_value",
112
+ "numbers__place_value_composed",
113
+ "numbers__round_number",
114
+ "numbers__round_number_composed",
115
+ "polynomials__add",
116
+ "polynomials__coefficient_named",
117
+ "polynomials__collect",
118
+ "polynomials__compose",
119
+ "polynomials__evaluate",
120
+ "polynomials__evaluate_composed",
121
+ "polynomials__expand",
122
+ "polynomials__simplify_power",
123
+ "probability__swr_p_level_set",
124
+ "probability__swr_p_sequence",
125
+ # train-easy train-medium train-hard
126
+ "algebra__linear_1d",
127
+ "algebra__linear_1d_composed",
128
+ "algebra__linear_2d",
129
+ "algebra__linear_2d_composed",
130
+ "algebra__polynomial_roots",
131
+ "algebra__polynomial_roots_composed",
132
+ "algebra__sequence_next_term",
133
+ "algebra__sequence_nth_term",
134
+ "arithmetic__add_or_sub",
135
+ "arithmetic__add_or_sub_in_base",
136
+ "arithmetic__add_sub_multiple",
137
+ "arithmetic__div",
138
+ "arithmetic__mixed",
139
+ "arithmetic__mul",
140
+ "arithmetic__mul_div_multiple",
141
+ "arithmetic__nearest_integer_root",
142
+ "arithmetic__simplify_surd",
143
+ "calculus__differentiate",
144
+ "calculus__differentiate_composed",
145
+ "comparison__closest",
146
+ "comparison__closest_composed",
147
+ "comparison__kth_biggest",
148
+ "comparison__kth_biggest_composed",
149
+ "comparison__pair",
150
+ "comparison__pair_composed",
151
+ "comparison__sort",
152
+ "comparison__sort_composed",
153
+ "measurement__conversion",
154
+ "measurement__time",
155
+ "numbers__base_conversion",
156
+ "numbers__div_remainder",
157
+ "numbers__div_remainder_composed",
158
+ "numbers__gcd",
159
+ "numbers__gcd_composed",
160
+ "numbers__is_factor",
161
+ "numbers__is_factor_composed",
162
+ "numbers__is_prime",
163
+ "numbers__is_prime_composed",
164
+ "numbers__lcm",
165
+ "numbers__lcm_composed",
166
+ "numbers__list_prime_factors",
167
+ "numbers__list_prime_factors_composed",
168
+ "numbers__place_value",
169
+ "numbers__place_value_composed",
170
+ "numbers__round_number",
171
+ "numbers__round_number_composed",
172
+ "polynomials__add",
173
+ "polynomials__coefficient_named",
174
+ "polynomials__collect",
175
+ "polynomials__compose",
176
+ "polynomials__evaluate",
177
+ "polynomials__evaluate_composed",
178
+ "polynomials__expand",
179
+ "polynomials__simplify_power",
180
+ "probability__swr_p_level_set",
181
+ "probability__swr_p_sequence",
182
+ ]
183
+
184
+ _QUESTION = "question"
185
+ _ANSWER = "answer"
186
+
187
+ _DATASET_VERSION = "mathematics_dataset-v1.0"
188
+
189
+
190
+ def _generate_builder_configs():
191
+ """Generate configs with different subsets of mathematics dataset."""
192
+ configs = []
193
+ for module in sorted(set(_MODULES)):
194
+ configs.append(
195
+ datasets.BuilderConfig(
196
+ name=module,
197
+ version=datasets.Version("1.0.0"),
198
+ description=_DESCRIPTION,
199
+ )
200
+ )
201
+
202
+ return configs
203
+
204
+
205
+ class PortugueseMathDataset(datasets.GeneratorBasedBuilder):
206
+ """Math Dataset."""
207
+
208
+ BUILDER_CONFIGS = _generate_builder_configs()
209
+
210
+ def _info(self):
211
+ return datasets.DatasetInfo(
212
+ description=_DESCRIPTION,
213
+ features=datasets.Features(
214
+ {
215
+ _QUESTION: datasets.Value("string"),
216
+ _ANSWER: datasets.Value("string"),
217
+ }
218
+ ),
219
+ supervised_keys=(_QUESTION, _ANSWER),
220
+ homepage="https://github.com/deepmind/mathematics_dataset",
221
+ citation=_CITATION,
222
+ )
223
+
224
+ def _get_filepaths_from_categories(self, config, categories):
225
+ filepaths = []
226
+ for category in categories:
227
+ data_file = "/".join([_DATASET_VERSION, category, config])
228
+ filepaths.append(data_file)
229
+ return set(filepaths)
230
+
231
+ def _split_generators(self, dl_manager):
232
+ """Returns SplitGenerators."""
233
+
234
+ archive = dl_manager.download(_DATA_URL)
235
+ config = self.config.name + ".txt"
236
+
237
+ return [
238
+ datasets.SplitGenerator(
239
+ name=datasets.Split.TRAIN,
240
+ gen_kwargs={
241
+ "files": dl_manager.iter_archive(archive),
242
+ "config": config,
243
+ "categories": _TRAIN_CATEGORY,
244
+ },
245
+ ),
246
+ datasets.SplitGenerator(
247
+ name=datasets.Split.TEST,
248
+ gen_kwargs={
249
+ "files": dl_manager.iter_archive(archive),
250
+ "config": config,
251
+ "categories": _INTERPOLATE_CATEGORY,
252
+ },
253
+ ),
254
+ ]
255
+
256
+ def _generate_examples(self, files, config, categories):
257
+ """Yields examples based on directory, module file.."""
258
+
259
+ idx = 0
260
+ filepaths = self._get_filepaths_from_categories(config, categories)
261
+ for path, f in files:
262
+ if not filepaths:
263
+ break
264
+ elif path in filepaths:
265
+ for question in f:
266
+ if not question:
267
+ continue
268
+ else:
269
+ for answer in f:
270
+ if not answer:
271
+ continue
272
+ else:
273
+ yield idx, {_QUESTION: question, _ANSWER: answer}
274
+ idx += 1
275
+ break
276
+ filepaths.remove(path)