kundank commited on
Commit
8312457
1 Parent(s): 4bd10ca

Adding the builder script for the all_annotations view

Browse files
Files changed (1) hide show
  1. usb.py +23 -12
usb.py CHANGED
@@ -23,7 +23,7 @@ Paper can be found here : https://arxiv.org/abs/2305.14296
23
  class USBConfig(datasets.BuilderConfig):
24
  def __init__(
25
  self,
26
- text_features,
27
  label_column,
28
  citation=CITATION_BLOB,
29
  data_url="processed_data.tar.gz",
@@ -32,7 +32,7 @@ class USBConfig(datasets.BuilderConfig):
32
  **kwargs,
33
  ):
34
  super(USBConfig, self).__init__(version=datasets.Version("1.0.0", ""), **kwargs)
35
- self.text_features = text_features
36
  self.label_column = label_column
37
 
38
  self.citation = citation
@@ -50,51 +50,57 @@ class USB(datasets.GeneratorBasedBuilder):
50
  USBConfig(
51
  name="topicbased_summarization",
52
  description="Generate a short summary of the given article covering the given topic",
53
- text_features={"summ_idx": "int", "input_lines": "listsent", "topic_name": "sent", "output_lines":"listsent"},
54
  label_column="output_lines",
55
  ),
56
  USBConfig(
57
  name="fixing_factuality",
58
  description="Given a summary sentence (claim) and presented evidence from the article, edit the summary to remove unsupported or contradicting facts",
59
- text_features={"summ_idx": "int", "input_lines": "listsent", "initial_summary": "sent", "fixed_summary":"sent"},
60
  label_column="fixed_summary",
61
  ),
62
  USBConfig(
63
  name="unsupported_span_prediction",
64
  description="Given a summary sentence (claim) and presented evidence from the article, mark the parts of the summary which are not supported by the evidence by surrounding them with [] and [/] tags.",
65
- text_features={"summ_idx": "int", "input_lines": "listsent", "summary": "sent", "annotated_summary":"sent"},
66
  label_column="annotated_summary",
67
  ),
68
  USBConfig(
69
  name="evidence_extraction",
70
  description="Given an article and its summary, for each summary sentence, produce a minimal list of sentences from the article which provide sufficient evidence for all facts in the summary sentence.",
71
- text_features={"input_lines": "listsent", "summary_lines": "listsent", "evidence_labels":"listlistint"},
72
  label_column="evidence_labels",
73
  ),
74
  USBConfig(
75
  name="multisentence_compression",
76
  description="Given a list of sentences from an article, generate a single sentence summary of the presented cluster of sentences.",
77
- text_features={"summ_idx": "int", "input_lines": "listsent", "output_lines": "listsent"},
78
  label_column="output_lines",
79
  ),
80
  USBConfig(
81
  name="extractive_summarization",
82
  description="Given an article, generate an extractive summary by producing a subset o the article's sentences",
83
- text_features={"input_lines": "listsent", "labels": "listint"},
84
  label_column="labels",
85
  ),
86
  USBConfig(
87
  name="abstractive_summarization",
88
  description="Given an article, generate its abstractive summary",
89
- text_features={"input_lines": "listsent", "output_lines": "listsent"},
90
  label_column="output_lines",
91
  ),
92
  USBConfig(
93
  name="factuality_classification",
94
  description="Given a summary sentence (claim) and presented evidence from the article, predict whether all facts of the claim are supported by and in agreement with the presented evidence, or not.",
95
- text_features={"summ_idx": "int", "input_lines": "listsent", "summary_sent": "sent", "label":"int"},
96
  label_column="label",
97
  ),
 
 
 
 
 
 
98
  ]
99
 
100
  def _split_generators(self, dl_manager):
@@ -136,8 +142,13 @@ class USB(datasets.GeneratorBasedBuilder):
136
  features = {}
137
  features["id"] = datasets.Value("string")
138
  features["domain"] = datasets.Value("string")
 
 
 
 
 
139
 
140
- for (text_feature,dtype) in self.config.text_features.items():
141
  hf_dtype = None
142
  if dtype=="int":
143
  hf_dtype = datasets.Value("int32")
@@ -152,7 +163,7 @@ class USB(datasets.GeneratorBasedBuilder):
152
  else:
153
  raise NotImplementedError
154
 
155
- features[text_feature] = hf_dtype
156
 
157
  return datasets.DatasetInfo(
158
  description=DESCRIPTION_BLOB,
 
23
  class USBConfig(datasets.BuilderConfig):
24
  def __init__(
25
  self,
26
+ featurespec,
27
  label_column,
28
  citation=CITATION_BLOB,
29
  data_url="processed_data.tar.gz",
 
32
  **kwargs,
33
  ):
34
  super(USBConfig, self).__init__(version=datasets.Version("1.0.0", ""), **kwargs)
35
+ self.featurespec = featurespec
36
  self.label_column = label_column
37
 
38
  self.citation = citation
 
50
  USBConfig(
51
  name="topicbased_summarization",
52
  description="Generate a short summary of the given article covering the given topic",
53
+ featurespec={"summ_idx": "int", "input_lines": "listsent", "topic_name": "sent", "output_lines":"listsent"},
54
  label_column="output_lines",
55
  ),
56
  USBConfig(
57
  name="fixing_factuality",
58
  description="Given a summary sentence (claim) and presented evidence from the article, edit the summary to remove unsupported or contradicting facts",
59
+ featurespec={"summ_idx": "int", "input_lines": "listsent", "initial_summary": "sent", "fixed_summary":"sent"},
60
  label_column="fixed_summary",
61
  ),
62
  USBConfig(
63
  name="unsupported_span_prediction",
64
  description="Given a summary sentence (claim) and presented evidence from the article, mark the parts of the summary which are not supported by the evidence by surrounding them with [] and [/] tags.",
65
+ featurespec={"summ_idx": "int", "input_lines": "listsent", "summary": "sent", "annotated_summary":"sent"},
66
  label_column="annotated_summary",
67
  ),
68
  USBConfig(
69
  name="evidence_extraction",
70
  description="Given an article and its summary, for each summary sentence, produce a minimal list of sentences from the article which provide sufficient evidence for all facts in the summary sentence.",
71
+ featurespec={"input_lines": "listsent", "summary_lines": "listsent", "evidence_labels":"listlistint"},
72
  label_column="evidence_labels",
73
  ),
74
  USBConfig(
75
  name="multisentence_compression",
76
  description="Given a list of sentences from an article, generate a single sentence summary of the presented cluster of sentences.",
77
+ featurespec={"summ_idx": "int", "input_lines": "listsent", "output_lines": "listsent"},
78
  label_column="output_lines",
79
  ),
80
  USBConfig(
81
  name="extractive_summarization",
82
  description="Given an article, generate an extractive summary by producing a subset o the article's sentences",
83
+ featurespec={"input_lines": "listsent", "labels": "listint"},
84
  label_column="labels",
85
  ),
86
  USBConfig(
87
  name="abstractive_summarization",
88
  description="Given an article, generate its abstractive summary",
89
+ featurespec={"input_lines": "listsent", "output_lines": "listsent"},
90
  label_column="output_lines",
91
  ),
92
  USBConfig(
93
  name="factuality_classification",
94
  description="Given a summary sentence (claim) and presented evidence from the article, predict whether all facts of the claim are supported by and in agreement with the presented evidence, or not.",
95
+ featurespec={"summ_idx": "int", "input_lines": "listsent", "summary_sent": "sent", "label":"int"},
96
  label_column="label",
97
  ),
98
+ USBConfig(
99
+ name="all_annotations",
100
+ description="All annotations collected in the creation of USB dataset in one place.",
101
+ featurespec={},
102
+ label_column=None,
103
+ ),
104
  ]
105
 
106
  def _split_generators(self, dl_manager):
 
142
  features = {}
143
  features["id"] = datasets.Value("string")
144
  features["domain"] = datasets.Value("string")
145
+
146
+ if self.config.name=="all_annotations":
147
+ # handle this as a special case
148
+ features["source"] = datasets.Sequence({"txt": datasets.Value("string"), "section_name": datasets.Value("string"), "section_index": datasets.Value("int32"), "is_header":datasets.Value("bool")})
149
+ features["summary"] = datasets.Sequence({"pre_edit": datasets.Value("string"), "post_edit": datasets.Value("string"), "evidence": datasets.Sequence(datasets.Value("int32"))})
150
 
151
+ for (feature_name,dtype) in self.config.featurespec.items():
152
  hf_dtype = None
153
  if dtype=="int":
154
  hf_dtype = datasets.Value("int32")
 
163
  else:
164
  raise NotImplementedError
165
 
166
+ features[feature_name] = hf_dtype
167
 
168
  return datasets.DatasetInfo(
169
  description=DESCRIPTION_BLOB,