File size: 1,092 Bytes
8540cd1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#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;
}