Spaces:
Runtime error
Runtime error
Download tests/test_preprocessing.py from vishnu-coder/twitter-sentiment-app: direct link, hf CLI and curl.
- Browser
- Download file 800 Bytes
-
https://huggingface.co/spaces/vishnu-coder/twitter-sentiment-app/resolve/main/tests/test_preprocessing.py
- Command line
-
hf download hf://spaces/vishnu-coder/twitter-sentiment-app/tests/test_preprocessing.py
-
curl -L -o test_preprocessing.py https://huggingface.co/spaces/vishnu-coder/twitter-sentiment-app/resolve/main/tests/test_preprocessing.py
800 Bytes
| from __future__ import annotations | |
| import pandas as pd | |
| from twitter_sentiment.config import load_config, Config | |
| from twitter_sentiment.preprocessing import clean_text, preprocess_dataframe | |
| def test_clean_text_removes_urls_mentions(tmp_path): | |
| config = load_config() | |
| result = clean_text("Check this https://example.com @user", config) | |
| assert "http" not in result | |
| assert "@" not in result | |
| def test_preprocess_dataframe_returns_expected_columns(tmp_path): | |
| config = load_config() | |
| df = pd.DataFrame({ | |
| config.data["text_column"]: ["Great flight!"], | |
| config.data["target_column"]: ["positive"], | |
| }) | |
| processed = preprocess_dataframe(df, config) | |
| assert processed.shape == (1, 2) | |
| assert processed[config.data["text_column"]].iloc[0] == "great flight" | |