File size: 2,073 Bytes
1aa55a9
 
 
 
 
 
 
 
 
 
 
72f6370
 
 
1aa55a9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
"""ReRelEM dataset"""

import datasets
import pandas as pd

_CITATION = """
"""

_DESCRIPTION = """
"""
_URLS = {
    "train": "https://raw.githubusercontent.com/ruanchaves/rerelem/9de7c418879b010a8ca9940639cac900bd27d9fd/rerelem_train.csv",
    "validation": "https://raw.githubusercontent.com/ruanchaves/rerelem/9de7c418879b010a8ca9940639cac900bd27d9fd/rerelem_val.csv",
    "test": "https://raw.githubusercontent.com/ruanchaves/rerelem/9de7c418879b010a8ca9940639cac900bd27d9fd/rerelem_test.csv"
}

class ReRelEm(datasets.GeneratorBasedBuilder):

    VERSION = datasets.Version("1.0.0")
    def _info(self):
        return datasets.DatasetInfo(
            description=_DESCRIPTION,
            features=datasets.Features(
                {
                    "docid": datasets.Value("string"),
                    "sentence1": datasets.Value("string"),
                    "sentence2": datasets.Value("string"),
                    "label": datasets.Value("string"),
                    "same_text": datasets.Value("bool"),
                    }),
            supervised_keys=None,
            homepage="",
            citation=_CITATION,
        )

    def _split_generators(self, dl_manager):
        downloaded_files = dl_manager.download(_URLS)
        return [
            datasets.SplitGenerator(
                name=datasets.Split.TRAIN,
                gen_kwargs={
                    "filepath": downloaded_files["train"]
                }
            ),
            datasets.SplitGenerator(
                name=datasets.Split.VALIDATION,
                gen_kwargs={
                    "filepath": downloaded_files["validation"]
                }
            ),    
            datasets.SplitGenerator(
                name=datasets.Split.TEST,
                gen_kwargs={
                    "filepath": downloaded_files["test"]
                }
            )        
        ]

    def _generate_examples(self, filepath):
        records = pd.read_csv(filepath).to_dict("records")
        for idx, row in enumerate(records):
            yield idx, row