MCPcopy Create free account
hub / github.com/OpenBMB/DecT / SST2Processor

Class SST2Processor

src/process_data.py:204–231  ·  view source on GitHub ↗

`SST-2 `_ dataset is a dataset for sentiment analysis. It is a modified version containing only binary labels (negative or somewhat negative vs somewhat positive or positive with neutral sentences discarded) on top of the original 5-labeled dataset

Source from the content-addressed store, hash-verified

202
203
204class SST2Processor(DataProcessor):
205 """
206 `SST-2 <https://nlp.stanford.edu/sentiment/index.html>`_ dataset is a dataset for sentiment analysis. It is a modified version containing only binary labels (negative or somewhat negative vs somewhat positive or positive with neutral sentences discarded) on top of the original 5-labeled dataset released first in `Recursive Deep Models for Semantic Compositionality Over a Sentiment Treebank <https://aclanthology.org/D13-1170.pdf>`_
207
208 We use the data released in `Making Pre-trained Language Models Better Few-shot Learners (Gao et al. 2020) <https://arxiv.org/pdf/2012.15723.pdf>`_
209
210 """
211 dataset_project = {"train": "train",
212 "dev": "train",
213 "test": "dev"
214 }
215 def __init__(self):
216 super().__init__()
217 self.labels = ['0', '1']
218
219 def get_examples(self, data_dir, split):
220 path = os.path.join(data_dir, f"{self.dataset_project[split]}.tsv")
221 examples = []
222 with open(path, encoding='utf-8')as f:
223 lines = f.readlines()
224 for idx, line in enumerate(lines[1:]):
225 linelist = line.strip().split('\t')
226 text_a = linelist[0]
227 label = linelist[1]
228 guid = "%s-%s" % (split, idx)
229 example = InputExample(guid=guid, text_a=text_a, label=self.get_label_id(label))
230 examples.append(example)
231 return examples
232
233
234class SnliProcessor(DataProcessor):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected