Datasets:

Languages:
Indonesian
ArXiv:
File size: 4,691 Bytes
44bab8a
 
 
 
 
 
28d489b
 
 
44bab8a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28d489b
44bab8a
 
 
 
 
 
 
 
 
 
 
28d489b
44bab8a
 
28d489b
44bab8a
 
 
 
 
 
28d489b
 
 
44bab8a
28d489b
44bab8a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28d489b
44bab8a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28d489b
44bab8a
 
 
 
 
 
 
 
 
 
 
 
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import os
from pathlib import Path
from typing import Dict, List, Tuple

import datasets

from seacrowd.utils.configs import SEACrowdConfig
from seacrowd.utils.constants import Tasks
from seacrowd.utils import schemas
import json

_CITATION = """\
@misc{quoraFirstQuora,
	author = {},
	title = {{F}irst {Q}uora {D}ataset {R}elease: {Q}uestion {P}airs --- quoradata.quora.com},
	howpublished = {https://quoradata.quora.com/First-Quora-Dataset-Release-Question-Pairs},
	year = 2017,
	note = {Online},
}
"""

_LANGUAGES = ["ind"]  # We follow ISO639-3 language code (https://iso639-3.sil.org/code_tables/639/data)
_LOCAL = False

_DATASETNAME = "id_qqp"

_DESCRIPTION = """\
Quora Question Pairs (QQP) dataset consists of over 400,000 question pairs, 
and each question pair is annotated with a binary value indicating whether 
the two questions are paraphrase of each other. This dataset is translated 
version of QQP to Indonesian Language.
"""

_HOMEPAGE = "https://github.com/louisowen6/quora_paraphrasing_id"

_LICENSE = "Apache License, Version 2.0"

_URLS = {
    _DATASETNAME: [
        "https://github.com/louisowen6/quora_paraphrasing_id/raw/main/ID_Quora_Paraphrasing_train.json",
        "https://github.com/louisowen6/quora_paraphrasing_id/raw/main/ID_Quora_Paraphrasing_val.json",
    ]
}

_SUPPORTED_TASKS = [Tasks.PARAPHRASING]

_SOURCE_VERSION = "1.0.0"

_SEACROWD_VERSION = "2024.06.20"


class IdQuoraQuestionPairs(datasets.GeneratorBasedBuilder):
    """
    Quora Question Pairs (QQP) dataset consists of over 400,000 question pairs, 
    and each question pair is annotated with a binary value indicating whether 
    the two questions are paraphrase of each other. This dataset is translated 
    version of QQP to Indonesian Language.
    """

    SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
    SEACROWD_VERSION = datasets.Version(_SEACROWD_VERSION)
    
    BUILDER_CONFIGS = [
        SEACrowdConfig(
            name="id_qqp_source",
            version=SOURCE_VERSION,
            description="ID QQP source schema",
            schema="source",
            subset_id="id_qqp",
        ),
        SEACrowdConfig(
            name="id_qqp_seacrowd_t2t",
            version=SEACROWD_VERSION,
            description="ID QQP Nusantara schema",
            schema="seacrowd_t2t",
            subset_id="id_qqp",
        ),
    ]

    DEFAULT_CONFIG_NAME = "id_qqp_source"

    def _info(self) -> datasets.DatasetInfo:

        if self.config.schema == "source":

            features = datasets.Features(
               {
                   "id": datasets.Value("string"),
                   "question_1": datasets.Value("string"),
                   "question_2": datasets.Value("string")
               }
            )

        elif self.config.schema == "seacrowd_t2t":
            features = schemas.text2text_features

        return datasets.DatasetInfo(
            description=_DESCRIPTION,
            features=features,
            homepage=_HOMEPAGE,
            license=_LICENSE,
            citation=_CITATION,
        )


    def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
        urls = _URLS[_DATASETNAME]
        data_dir = dl_manager.download_and_extract(urls)
        return [
            datasets.SplitGenerator(
                name=datasets.Split.TRAIN,
                gen_kwargs={
                    "filepath": data_dir[0],
                },
            ),
            datasets.SplitGenerator(
                name=datasets.Split.VALIDATION,
                gen_kwargs={
                    "filepath": data_dir[1],
                },
            ),
        ]

    def _generate_examples(self, filepath: Path) -> Tuple[int, Dict]:
        
        with open(filepath, "r") as f:
            lines = f.readlines()

        if self.config.schema == "source":
            
            for i, line in enumerate(lines):
                line = json.loads(line.strip())
                
                sample = {
                    "id": str(i),
                    "question_1": line["question_1"],
                    "question_2": line["question_2"]
                }
                yield i, sample

        elif self.config.schema == "seacrowd_t2t":
            
            for i, line in enumerate(lines):
                line = json.loads(line.strip())
                
                sample = {
                    "id": str(i),
                    "text_1": line["question_1"],
                    "text_2": line["question_2"],
                    "text_1_name": "question_1",
                    "text_2_name": "question_2"
                }
                yield i, sample