`AG News `_ is a News Topic classification dataset we use dataset provided by `LOTClass `_
| 98 | |
| 99 | |
| 100 | class AgnewsProcessor(DataProcessor): |
| 101 | """ |
| 102 | `AG News <https://arxiv.org/pdf/1509.01626.pdf>`_ is a News Topic classification dataset |
| 103 | |
| 104 | we use dataset provided by `LOTClass <https://github.com/yumeng5/LOTClass>`_ |
| 105 | """ |
| 106 | |
| 107 | def __init__(self): |
| 108 | super().__init__() |
| 109 | self.labels = ["World", "Sports", "Business", "Tech"] |
| 110 | |
| 111 | def get_examples(self, data_dir, split): |
| 112 | path = os.path.join(data_dir, "{}.csv".format(split)) |
| 113 | examples = [] |
| 114 | with open(path, encoding='utf8') as f: |
| 115 | reader = csv.reader(f, delimiter=',') |
| 116 | for idx, row in enumerate(reader): |
| 117 | label, headline, body = row |
| 118 | text_a = headline.replace('\\', ' ') |
| 119 | text_b = body.replace('\\', ' ') |
| 120 | example = InputExample(guid=str(idx), text_a=text_a, text_b=text_b, label=int(label)-1) |
| 121 | examples.append(example) |
| 122 | return examples |
| 123 | |
| 124 | class DBpediaProcessor(DataProcessor): |
| 125 | """ |
nothing calls this directly
no outgoing calls
no test coverage detected