Yahoo! Answers Topic Classification Dataset
| 177 | return labels |
| 178 | |
| 179 | class YahooProcessor(DataProcessor): |
| 180 | """ |
| 181 | Yahoo! Answers Topic Classification Dataset |
| 182 | """ |
| 183 | |
| 184 | def __init__(self): |
| 185 | super().__init__() |
| 186 | self.labels = ["Society & Culture", "Science & Mathematics", "Health", "Education & Reference", "Computers & Internet", "Sports", "Business & Finance", "Entertainment & Music" |
| 187 | ,"Family & Relationships", "Politics & Government"] |
| 188 | |
| 189 | def get_examples(self, data_dir, split): |
| 190 | path = os.path.join(data_dir, "{}.csv".format(split)) |
| 191 | examples = [] |
| 192 | with open(path, encoding='utf8') as f: |
| 193 | reader = csv.reader(f, delimiter=',') |
| 194 | for idx, row in enumerate(reader): |
| 195 | label, question_title, question_body, answer = row |
| 196 | text_a = ' '.join([question_title.replace('\\n', ' ').replace('\\', ' '), |
| 197 | question_body.replace('\\n', ' ').replace('\\', ' ')]) |
| 198 | text_b = answer.replace('\\n', ' ').replace('\\', ' ') |
| 199 | example = InputExample(guid=str(idx), text_a=text_a, text_b=text_b, label=int(label)-1) |
| 200 | examples.append(example) |
| 201 | return examples |
| 202 | |
| 203 | |
| 204 | class SST2Processor(DataProcessor): |
nothing calls this directly
no outgoing calls
no test coverage detected