Datasets:

Modalities:
Text
ArXiv:
Libraries:
Datasets
License:
Muennighoff commited on
Commit
37c1004
β€’
1 Parent(s): eb2ad9a
README.md CHANGED
@@ -1,3 +1,13 @@
 
 
 
 
 
 
 
 
 
 
1
  ## XWinograd
2
 
3
  Multilingual winograd schema challenge.
 
1
+ ---
2
+ language:
3
+ - en
4
+ - fr
5
+ - jp
6
+ - pt
7
+ - ru
8
+ - zh
9
+ ---
10
+
11
  ## XWinograd
12
 
13
  Multilingual winograd schema challenge.
raw_data/convert_tsv.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import random
3
+
4
+ def winogrande_format(row):
5
+ array = row["pronoun"]
6
+ position_idx = json.loads(array)[1][0]
7
+ # Turn unicode into proper chinese characters
8
+ sent = str(u"{}".format(row["sent"]))
9
+ start_idx = 0
10
+ for i, tok in enumerate(json.loads(row["toks"])):
11
+ tok = str(u"{}".format(tok))
12
+ cur_start_idx = sent.find(tok)
13
+ if i == position_idx:
14
+ break
15
+ sent = sent[cur_start_idx + len(tok):]
16
+ start_idx += cur_start_idx + len(tok)
17
+ # +1 to give room for an optional space
18
+ row["sentence"] = row["sent"][:start_idx] + row["sent"][start_idx:start_idx+len(tok)+1].replace(tok, "_") + row["sent"][start_idx+len(tok)+1:]
19
+
20
+ sol = json.loads(row["solution"])
21
+
22
+ cor_answer_idx = random.choice([1, 2])
23
+ incor_answer_idx = 2 if cor_answer_idx == 1 else 1
24
+
25
+ cor_answer = str(u"{}".format(sol[0][0])) if sol[0][-1] == True else str(u"{}".format(sol[1][0]))
26
+ incor_answer = str(u"{}".format(sol[0][0])) if sol[0][-1] == False else str(u"{}".format(sol[1][0]))
27
+
28
+ row[f"option{cor_answer_idx}"] = cor_answer
29
+ row[f"option{incor_answer_idx}"] = incor_answer
30
+ row["answer"] = cor_answer_idx
31
+ return row
32
+
33
+ # ds = ds.apply(winogrande_format, axis=1)
{data β†’ raw_data}/xwinograd.tsv RENAMED
File without changes
test/{en.json β†’ en.jsonl} RENAMED
File without changes
test/{fr.json β†’ fr.jsonl} RENAMED
File without changes
test/{jp.json β†’ jp.jsonl} RENAMED
File without changes
test/{pt.json β†’ pt.jsonl} RENAMED
File without changes
test/{ru.json β†’ ru.jsonl} RENAMED
File without changes
test/{zh.json β†’ zh.jsonl} RENAMED
File without changes
xwinograd.py CHANGED
@@ -1,10 +1,7 @@
1
  """XWinograd"""
2
 
3
-
4
  import json
5
 
6
- import pandas as pd
7
-
8
  import datasets
9
 
10
 
@@ -61,7 +58,7 @@ class XWinograd(datasets.GeneratorBasedBuilder):
61
 
62
  def _split_generators(self, dl_manager):
63
 
64
- downloaded_files = dl_paths = dl_manager.download(_URL.format(lang=self.config.name))
65
  return [
66
  datasets.SplitGenerator(
67
  name=datasets.Split.TEST,
@@ -71,14 +68,14 @@ class XWinograd(datasets.GeneratorBasedBuilder):
71
 
72
  def _generate_examples(self, filepath):
73
  """This function returns the examples in the raw (text) form."""
74
- logger.info("generating examples from = %s", filepath)
75
 
76
  with open(filepath, encoding="utf-8") as f:
77
  for id_, row in enumerate(f):
78
  data = json.loads(row)
79
 
80
  yield id_, {
81
- "sentence": data["sent"],
82
  "option1": data["option1"],
83
  "option2": data["option2"],
84
  "answer": data["answer"],
 
1
  """XWinograd"""
2
 
 
3
  import json
4
 
 
 
5
  import datasets
6
 
7
 
 
58
 
59
  def _split_generators(self, dl_manager):
60
 
61
+ downloaded_files = dl_manager.download(_URL.format(lang=self.config.name))
62
  return [
63
  datasets.SplitGenerator(
64
  name=datasets.Split.TEST,
 
68
 
69
  def _generate_examples(self, filepath):
70
  """This function returns the examples in the raw (text) form."""
71
+ logger.info("Generating examples from = %s", filepath)
72
 
73
  with open(filepath, encoding="utf-8") as f:
74
  for id_, row in enumerate(f):
75
  data = json.loads(row)
76
 
77
  yield id_, {
78
+ "sentence": data["sentence"],
79
  "option1": data["option1"],
80
  "option2": data["option2"],
81
  "answer": data["answer"],