File size: 979 Bytes
d7013e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from abc import ABC, abstractmethod
from typing import Self

from torch.utils.data import DataLoader


class IDataset(ABC):
    """Interface for dataset loading and preprocessing."""

    @abstractmethod
    def load(self, path: str) -> Self:
        """Load dataset from path."""
        ...

    @abstractmethod
    def clean(self) -> Self:
        """Clean and filter the dataset."""
        ...

    @abstractmethod
    def preprocess(self) -> Self:
        """Preprocess dataset (extract features, tokenize labels)."""
        ...

    @abstractmethod
    def split(self, train_ratio: float = 0.8, val_ratio: float = 0.1) -> Self:
        """Split into train/val/test sets."""
        ...

    @abstractmethod
    def get_train_loader(self, batch_size: int) -> DataLoader:
        ...

    @abstractmethod
    def get_val_loader(self, batch_size: int) -> DataLoader:
        ...

    @abstractmethod
    def get_test_loader(self, batch_size: int) -> DataLoader:
        ...