import sys import os # Add current directory to path to import sentiment_app sys.path.append(os.getcwd()) try: from sentiment_app import SentimentAnalyzer except ImportError: # If running from a different directory, might need to adjust path print("Could not import sentiment_app. Make sure you are in the correct directory.") sys.exit(1) def test_model(): print("Testing SentimentAnalyzer...") analyzer = SentimentAnalyzer() if analyzer.classifier is None: print("FATAL: Classifier failed to load.") return print("Classifier loaded. Testing prediction...") text = "I love this library!" result = analyzer.analyze(text) print(f"Prediction result for '{text}':") print(result) if result['sentiment'] == 'Error': print("FATAL: Prediction returned Error.") else: print("SUCCESS: Prediction worked.") if __name__ == "__main__": test_model()