From 4394db1810954500baa7b207b40f57fc829a05ce Mon Sep 17 00:00:00 2001 From: Cyril Date: Sun, 12 Oct 2025 11:39:34 +0200 Subject: [PATCH 1/2] Refactor sentiment result formatting and improve import organization --- src/cli/display.py | 3 ++- src/main.py | 31 +++++++++++++++++++++---------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/cli/display.py b/src/cli/display.py index 5c5676c..0cf8601 100644 --- a/src/cli/display.py +++ b/src/cli/display.py @@ -11,8 +11,9 @@ class DisplayFormatter: return f"āŒ {result['error']}" sentiment = result["sentiment"] + print(sentiment) confidence = result["confidence"] - emoji = "😊" if sentiment == "POSITIVE" else "šŸ˜ž" + emoji = "😊" if sentiment == "positive" else "šŸ˜ž" return f"{emoji} Sentiment: {sentiment}\nšŸ“Š Confidence: {confidence:.2%}" diff --git a/src/main.py b/src/main.py index a9d559e..aa16046 100644 --- a/src/main.py +++ b/src/main.py @@ -6,10 +6,16 @@ import sys from pathlib import Path # Add parent directory to PYTHONPATH -sys.path.insert(0, str(Path(__file__).parent.parent)) +sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) from src.cli import InteractiveCLI -from src.commands import SentimentCommand, FillMaskCommand, TextGenCommand, ModerationCommand, NERCommand +from src.commands import ( + FillMaskCommand, + ModerationCommand, + NERCommand, + SentimentCommand, + TextGenCommand, +) def main(): @@ -17,22 +23,27 @@ def main(): try: # Create CLI interface cli = InteractiveCLI() - + # Register available commands - cli.register_command(SentimentCommand()) - cli.register_command(FillMaskCommand()) - cli.register_command(TextGenCommand()) - cli.register_command(ModerationCommand()) - cli.register_command(NERCommand()) - + commands_to_register = [ + SentimentCommand, + FillMaskCommand, + TextGenCommand, + ModerationCommand, + NERCommand, + ] + for command in commands_to_register: + cli.register_command(command()) + # Launch interactive interface cli.run() - + except KeyboardInterrupt: print("\nšŸ‘‹ Stopping program") except Exception as e: print(f"āŒ Error: {e}") sys.exit(1) + if __name__ == "__main__": main() -- 2.40.1 From b990f802637e6d38818a2c451d7bf4d9b3c77ded Mon Sep 17 00:00:00 2001 From: Cyril Date: Sun, 12 Oct 2025 11:40:39 +0200 Subject: [PATCH 2/2] Fix sentiment result formatting by removing debug print statement --- src/cli/display.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cli/display.py b/src/cli/display.py index 0cf8601..df2dc27 100644 --- a/src/cli/display.py +++ b/src/cli/display.py @@ -11,7 +11,6 @@ class DisplayFormatter: return f"āŒ {result['error']}" sentiment = result["sentiment"] - print(sentiment) confidence = result["confidence"] emoji = "😊" if sentiment == "positive" else "šŸ˜ž" -- 2.40.1