duqing2026's picture
Init C++ Sentiment Analyzer (fixed binary)
8540cd1
#include "SentimentAnalyzer.hpp"
#include <iostream>
#include <string>
void print_help() {
std::cout << "Sentiment Analyzer CLI\n";
std::cout << "Usage:\n";
std::cout << " Type a sentence to analyze its sentiment.\n";
std::cout << " Type 'quit' or 'exit' to close the application.\n";
}
int main() {
SentimentAnalyzer analyzer;
std::string input;
print_help();
while (true) {
std::cout << "\n> ";
if (!std::getline(std::cin, input)) {
break;
}
if (input == "quit" || input == "exit") {
break;
}
if (input.empty()) continue;
double score = analyzer.analyze(input);
std::cout << "Score: " << score << " ";
if (score > 0.5) std::cout << "😊 (Very Positive)";
else if (score > 0) std::cout << "🙂 (Positive)";
else if (score == 0) std::cout << "😐 (Neutral)";
else if (score > -0.5) std::cout << "🙁 (Negative)";
else std::cout << "😠 (Very Negative)";
std::cout << std::endl;
}
return 0;
}