| import os |
| import sys |
|
|
| |
| sys.path.append(os.path.dirname(os.path.abspath(__file__))) |
|
|
| from main import map_distilroberta_emotions |
|
|
| def test_mapping(): |
| print("Testing DistilRoBERTa emotion mapping logic...") |
| |
| |
| anger_test = [{"label": "anger", "score": 0.8}, {"label": "neutral", "score": 0.2}] |
| assert map_distilroberta_emotions(anger_test) == "frustration", f"Expected frustration, got {map_distilroberta_emotions(anger_test)}" |
| |
| disgust_test = [{"label": "disgust", "score": 0.6}] |
| assert map_distilroberta_emotions(disgust_test) == "frustration", f"Expected frustration, got {map_distilroberta_emotions(disgust_test)}" |
| |
| |
| sadness_test = [{"label": "sadness", "score": 0.9}] |
| assert map_distilroberta_emotions(sadness_test) == "confusion", f"Expected confusion, got {map_distilroberta_emotions(sadness_test)}" |
| |
| surprise_test = [{"label": "surprise", "score": 0.55}] |
| assert map_distilroberta_emotions(surprise_test) == "confusion", f"Expected confusion, got {map_distilroberta_emotions(surprise_test)}" |
| |
| fear_test = [{"label": "fear", "score": 0.7}] |
| assert map_distilroberta_emotions(fear_test) == "confusion", f"Expected confusion, got {map_distilroberta_emotions(fear_test)}" |
| |
| |
| joy_test = [{"label": "joy", "score": 0.95}] |
| assert map_distilroberta_emotions(joy_test) == "confidence", f"Expected confidence, got {map_distilroberta_emotions(joy_test)}" |
| |
| |
| neutral_test = [{"label": "neutral", "score": 0.9}] |
| assert map_distilroberta_emotions(neutral_test) == "boredom", f"Expected boredom, got {map_distilroberta_emotions(neutral_test)}" |
|
|
| print("All DistilRoBERTa mapping assertions passed successfully!") |
|
|
| if __name__ == "__main__": |
| test_mapping() |
|
|