Spaces:
Sleeping
Sleeping
Download src/interface.py from minhtudragon/AI_Detector: direct link, hf CLI and curl.
- Browser
- Download file 964 Bytes
-
https://huggingface.co/spaces/minhtudragon/AI_Detector/resolve/main/src/interface.py
- Command line
-
hf download hf://spaces/minhtudragon/AI_Detector/src/interface.py
-
curl -L -o interface.py https://huggingface.co/spaces/minhtudragon/AI_Detector/resolve/main/src/interface.py
964 Bytes
| from abc import ABC, abstractmethod | |
| from typing import List | |
| class ParaphrasingModel(ABC): | |
| """ | |
| Abstract base class for paraphrasing models (e.g., T5, GPT). | |
| """ | |
| 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). | |
| """ | |
| def process(self, text: str, paraphraser: ParaphrasingModel) -> str: | |
| """ | |
| Process a block of text using the provided paraphraser. | |
| """ | |
| pass | |