I already read the tutorial about TEXT CLASSIFICATION WITH TORCHTEXT 2.
I want to do my custom text classification task, but there are some different between torch.data and torchtext.data.
take a look in the tutorial.

import torch
import torchtext
from torchtext.datasets import text_classification
NGRAMS = 2
import os
if not os.path.isdir(’./.data’):
os.mkdir(’./.data’)
train_dataset, test_dataset = text_classification.DATASETS[‘AG_NEWS’](
root=’./.data’, ngrams=NGRAMS, vocab=None)
BATCH_SIZE = 16
device = torch.device(“cuda” if torch.cuda.is_available() else “cpu”)

In these example, datasets are load after download.
If I have a custom data look like “train.csv”.
This “train.csv” is a table, have two columns.
One of column name is “text”, containing text.
One of column name is “label”, containing my target.




text
label




this is an apple
0


NBA is started today
1


We are family
2



How to write a standard torchtext.data class in these case?