AI_Detector / src /interface.py
Tany Nguyen
Init repo
1182571
raw
history blame contribute delete
964 Bytes
from abc import ABC, abstractmethod
from typing import List
class ParaphrasingModel(ABC):
"""
Abstract base class for paraphrasing models (e.g., T5, GPT).
"""
@abstractmethod
def paraphrase(self, text: str) -> str:
"""Paraphrase the given text."""
pass
def paraphrase_batch(self, texts: List[str]) -> List[str]:
"""
Paraphrase a list of texts.
Default implementation loops, but subclasses should override for GPU batching.
"""
return [self.paraphrase(text) for text in texts]
class TextProcessingMode(ABC):
"""
Abstract base class for text processing modes (Strategy Pattern).
Defines HOW the text is broken down and processed (e.g., by paragraph, random sentences).
"""
@abstractmethod
def process(self, text: str, paraphraser: ParaphrasingModel) -> str:
"""
Process a block of text using the provided paraphraser.
"""
pass