jupyterjazz commited on
Commit
296083a
1 Parent(s): 5ab80af

Delete xpqa.py

Browse files
Files changed (1) hide show
  1. xpqa.py +0 -62
xpqa.py DELETED
@@ -1,62 +0,0 @@
1
- import csv
2
- from typing import List
3
-
4
- import datasets
5
-
6
- LANGUAGES = ["ar", "de", "es", "fr", "hi", "it", "ja", "ko", "pl", "pt", "ta", "zh"]
7
- DATA_PATH = "test.csv"
8
-
9
-
10
- class XPQAConfig(datasets.BuilderConfig):
11
- def __init__(self, language, **kwargs):
12
- super().__init__(**kwargs)
13
- self.language = language
14
-
15
-
16
- class XPQA(datasets.GeneratorBasedBuilder):
17
- BUILDER_CONFIG_CLASS = XPQAConfig
18
-
19
- BUILDER_CONFIGS = [
20
- XPQAConfig(name=language, language=language) for language in LANGUAGES
21
- ]
22
-
23
- def _info(self):
24
- return datasets.DatasetInfo(
25
- description="xPQA is a large-scale annotated cross-lingual Product QA dataset.",
26
- features=datasets.Features(
27
- {
28
- "id": datasets.Value("string"),
29
- "question": datasets.Value("string"),
30
- "answer": datasets.Value("string"),
31
- }
32
- ),
33
- homepage="https://github.com/amazon-science/contextual-product-qa/tree/main?tab=readme-ov-file#xpqa",
34
- citation="https://arxiv.org/abs/2305.09249",
35
- )
36
-
37
- def _split_generators(
38
- self, dl_manager: datasets.DownloadManager
39
- ) -> List[datasets.SplitGenerator]:
40
- return [
41
- datasets.SplitGenerator(
42
- name=datasets.Split.TEST, gen_kwargs={"filepath": DATA_PATH}
43
- ),
44
- ]
45
-
46
- def _generate_examples(self, filepath):
47
- id_ = 0
48
- with open(filepath, newline="") as csvfile:
49
- csvreader = csv.reader(csvfile, delimiter=",")
50
- header = next(csvreader)
51
- lang_pos = header.index("lang")
52
- answer_pos = header.index("answer")
53
- question_pos = header.index("question")
54
- label_pos = header.index("label")
55
- for row in csvreader:
56
- if row[lang_pos] == self.config.language and row[label_pos] == "2":
57
- answer = row[answer_pos]
58
- question = row[question_pos]
59
- if not answer or not question:
60
- continue
61
- yield id_, {"id": id_, "question": question, "answer": answer}
62
- id_ += 1