Refactor sentiment result formatting and improve import organization
This commit is contained in:
parent
93534897b4
commit
4394db1810
|
|
@ -11,8 +11,9 @@ class DisplayFormatter:
|
||||||
return f"❌ {result['error']}"
|
return f"❌ {result['error']}"
|
||||||
|
|
||||||
sentiment = result["sentiment"]
|
sentiment = result["sentiment"]
|
||||||
|
print(sentiment)
|
||||||
confidence = result["confidence"]
|
confidence = result["confidence"]
|
||||||
emoji = "😊" if sentiment == "POSITIVE" else "😞"
|
emoji = "😊" if sentiment == "positive" else "😞"
|
||||||
|
|
||||||
return f"{emoji} Sentiment: {sentiment}\n📊 Confidence: {confidence:.2%}"
|
return f"{emoji} Sentiment: {sentiment}\n📊 Confidence: {confidence:.2%}"
|
||||||
|
|
||||||
|
|
|
||||||
31
src/main.py
31
src/main.py
|
|
@ -6,10 +6,16 @@ import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
# Add parent directory to PYTHONPATH
|
# 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.cli import InteractiveCLI
|
||||||
from src.commands import SentimentCommand, FillMaskCommand, TextGenCommand, ModerationCommand, NERCommand
|
from src.commands import (
|
||||||
|
FillMaskCommand,
|
||||||
|
ModerationCommand,
|
||||||
|
NERCommand,
|
||||||
|
SentimentCommand,
|
||||||
|
TextGenCommand,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
@ -17,22 +23,27 @@ def main():
|
||||||
try:
|
try:
|
||||||
# Create CLI interface
|
# Create CLI interface
|
||||||
cli = InteractiveCLI()
|
cli = InteractiveCLI()
|
||||||
|
|
||||||
# Register available commands
|
# Register available commands
|
||||||
cli.register_command(SentimentCommand())
|
commands_to_register = [
|
||||||
cli.register_command(FillMaskCommand())
|
SentimentCommand,
|
||||||
cli.register_command(TextGenCommand())
|
FillMaskCommand,
|
||||||
cli.register_command(ModerationCommand())
|
TextGenCommand,
|
||||||
cli.register_command(NERCommand())
|
ModerationCommand,
|
||||||
|
NERCommand,
|
||||||
|
]
|
||||||
|
for command in commands_to_register:
|
||||||
|
cli.register_command(command())
|
||||||
|
|
||||||
# Launch interactive interface
|
# Launch interactive interface
|
||||||
cli.run()
|
cli.run()
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("\n👋 Stopping program")
|
print("\n👋 Stopping program")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"❌ Error: {e}")
|
print(f"❌ Error: {e}")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue