PiC commited on
Commit
9d71fea
1 Parent(s): be181aa

Update phrase_sense_disambiguation.py

Browse files
Files changed (1) hide show
  1. phrase_sense_disambiguation.py +20 -11
phrase_sense_disambiguation.py CHANGED
@@ -28,14 +28,21 @@ logger = datasets.logging.get_logger(__name__)
28
 
29
 
30
  _CITATION = """\
 
 
 
 
 
 
31
  """
32
 
33
  _DESCRIPTION = """\
 
34
  """
35
 
36
- _HOMEPAGE = ""
37
 
38
- _LICENSE = "CC-BY-4.0"
39
 
40
  _URL = "https://auburn.edu/~tmp0038/PiC/"
41
  _SPLITS = {
@@ -64,7 +71,7 @@ class PhraseSenseDisambiguation(datasets.GeneratorBasedBuilder):
64
  BUILDER_CONFIGS = [
65
  PSDConfig(
66
  name=_PSD,
67
- version=datasets.Version("1.0.0"),
68
  description="The PiC Dataset for Phrase Sense Disambiguation at short passage level (~22 sentences)"
69
  )
70
  ]
@@ -77,13 +84,13 @@ class PhraseSenseDisambiguation(datasets.GeneratorBasedBuilder):
77
  "id": datasets.Value("string"),
78
  "title": datasets.Value("string"),
79
  "context": datasets.Value("string"),
80
- "query": datasets.Value("string"),
81
  "answers": datasets.Sequence(
82
  {
83
  "text": datasets.Value("string"),
84
  "answer_start": datasets.Value("int32"),
85
  }
86
- ),
87
  }
88
  ),
89
  # No default supervised_keys (as we have to pass both question and context as input).
@@ -95,7 +102,7 @@ class PhraseSenseDisambiguation(datasets.GeneratorBasedBuilder):
95
  QuestionAnsweringExtractive(
96
  question_column="question", context_column="context", answers_column="answers"
97
  )
98
- ],
99
  )
100
 
101
  def _split_generators(self, dl_manager):
@@ -117,21 +124,23 @@ class PhraseSenseDisambiguation(datasets.GeneratorBasedBuilder):
117
  logger.info("generating examples from = %s", filepath)
118
  key = 0
119
  with open(filepath, encoding="utf-8") as f:
120
- pic_pr = json.load(f)
121
- for example in pic_pr["data"]:
 
 
122
  answer_starts = [answer["answer_start"] for answer in example["answers"]]
123
  answers = [answer["text"] for answer in example["answers"]]
124
 
125
  # Features currently used are "context", "question", and "answers".
126
  # Others are extracted here for the ease of future expansions.
127
  yield key, {
128
- "title": example["title"],
129
  "context": example["context"],
130
- "query": example["question"],
131
  "id": example["id"],
132
  "answers": {
133
  "answer_start": answer_starts,
134
  "text": answers,
135
- },
136
  }
137
  key += 1
 
28
 
29
 
30
  _CITATION = """\
31
+ @article{pham2022PiC,
32
+ title={PiC: A Phrase-in-Context Dataset for Phrase Understanding and Semantic Search},
33
+ author={Pham, Thang M and Yoon, Seunghyun and Bui, Trung and Nguyen, Anh},
34
+ journal={arXiv preprint arXiv:2207.09068},
35
+ year={2022}
36
+ }
37
  """
38
 
39
  _DESCRIPTION = """\
40
+ Phrase in Context is a curated benchmark for phrase understanding and semantic search, consisting of three tasks of increasing difficulty: Phrase Similarity (PS), Phrase Retrieval (PR) and Phrase Sense Disambiguation (PSD). The datasets are annotated by 13 linguistic experts on Upwork and verified by two groups: ~1000 AMT crowdworkers and another set of 5 linguistic experts. PiC benchmark is distributed under CC-BY-NC 4.0.
41
  """
42
 
43
+ _HOMEPAGE = "https://phrase-in-context.github.io/"
44
 
45
+ _LICENSE = "CC-BY-NC-4.0"
46
 
47
  _URL = "https://auburn.edu/~tmp0038/PiC/"
48
  _SPLITS = {
 
71
  BUILDER_CONFIGS = [
72
  PSDConfig(
73
  name=_PSD,
74
+ version=datasets.Version("1.0.2"),
75
  description="The PiC Dataset for Phrase Sense Disambiguation at short passage level (~22 sentences)"
76
  )
77
  ]
 
84
  "id": datasets.Value("string"),
85
  "title": datasets.Value("string"),
86
  "context": datasets.Value("string"),
87
+ "question": datasets.Value("string"),
88
  "answers": datasets.Sequence(
89
  {
90
  "text": datasets.Value("string"),
91
  "answer_start": datasets.Value("int32"),
92
  }
93
+ )
94
  }
95
  ),
96
  # No default supervised_keys (as we have to pass both question and context as input).
 
102
  QuestionAnsweringExtractive(
103
  question_column="question", context_column="context", answers_column="answers"
104
  )
105
+ ]
106
  )
107
 
108
  def _split_generators(self, dl_manager):
 
124
  logger.info("generating examples from = %s", filepath)
125
  key = 0
126
  with open(filepath, encoding="utf-8") as f:
127
+ pic_psd = json.load(f)
128
+ for example in pic_psd["data"]:
129
+ title = example.get("title", "")
130
+
131
  answer_starts = [answer["answer_start"] for answer in example["answers"]]
132
  answers = [answer["text"] for answer in example["answers"]]
133
 
134
  # Features currently used are "context", "question", and "answers".
135
  # Others are extracted here for the ease of future expansions.
136
  yield key, {
137
+ "title": title,
138
  "context": example["context"],
139
+ "question": example["question"],
140
  "id": example["id"],
141
  "answers": {
142
  "answer_start": answer_starts,
143
  "text": answers,
144
+ }
145
  }
146
  key += 1