Download tests/test_preprocessor.py from devrup404/SignalMod: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/spaces/devrup404/SignalMod/resolve/21e8095f146314dd87fce3a1f63b090cf54ec99d/tests/test_preprocessor.py
- Command line
-
hf download hf://spaces/devrup404/SignalMod@21e8095f146314dd87fce3a1f63b090cf54ec99d/tests/test_preprocessor.py
-
curl -L -o test_preprocessor.py https://huggingface.co/spaces/devrup404/SignalMod/resolve/21e8095f146314dd87fce3a1f63b090cf54ec99d/tests/test_preprocessor.py
1.07 kB
| """Tests del pipeline de preprocesamiento de texto.""" | |
| import re | |
| import pytest | |
| from src.features.text_preprocessor import TextPreprocessor | |
| def preprocessor(features_config: str) -> TextPreprocessor: | |
| return TextPreprocessor(config_path=features_config) | |
| def test_empty_text_returns_empty_string(preprocessor: TextPreprocessor): | |
| assert preprocessor.transform("") == "" | |
| assert preprocessor.transform(" ") == "" | |
| def test_url_text_removes_urls(preprocessor: TextPreprocessor): | |
| raw = "Visit https://example.com/path and www.test.org now" | |
| clean = preprocessor.transform(raw) | |
| assert "http" not in clean | |
| assert "www." not in clean | |
| assert "example.com" not in clean | |
| assert re.search(r"https?://", clean) is None | |
| def test_normal_text_lowercase_and_lemmatized(preprocessor: TextPreprocessor): | |
| raw = "The runners are running quickly" | |
| clean = preprocessor.transform(raw) | |
| assert isinstance(clean, str) | |
| assert clean == clean.lower() | |
| assert clean != "" | |
| assert "run" in clean.split() | |