Spaces:
Sleeping
Sleeping
Download core/preprocess.py from BrainDrive/HealthEval: direct link, hf CLI and curl.
- Browser
- Download file 591 Bytes
-
https://huggingface.co/spaces/BrainDrive/HealthEval/resolve/main/core/preprocess.py
- Command line
-
hf download hf://spaces/BrainDrive/HealthEval/core/preprocess.py
-
curl -L -o preprocess.py https://huggingface.co/spaces/BrainDrive/HealthEval/resolve/main/core/preprocess.py
591 Bytes
| import re | |
| class Preprocessor: | |
| """ | |
| Preprocesses health queries for model input. | |
| Community note: Basic cleaning; extend for advanced NLP preprocessing if needed. | |
| """ | |
| def process_query(self, query: str) -> str: | |
| """ | |
| Clean and format the query. | |
| Community note: Removes extra whitespace and normalizes punctuation. | |
| """ | |
| if not query: | |
| return "" | |
| # Basic cleaning | |
| query = re.sub(r'\s+', ' ', query.strip()) | |
| query = re.sub(r'[^\w\s\?\.\,\!\-\']', '', query) # Keep common punctuation | |
| return query |