cpp-sentiment-analyzer / include /SentimentAnalyzer.hpp
duqing2026's picture
Init C++ Sentiment Analyzer (fixed binary)
8540cd1
raw
history blame contribute delete
800 Bytes
#ifndef SENTIMENT_ANALYZER_HPP
#define SENTIMENT_ANALYZER_HPP
#include <string>
#include <vector>
#include <map>
#include <string_view>
class SentimentAnalyzer {
public:
SentimentAnalyzer();
/**
* @brief Analyzes the sentiment of the given text.
*
* @param text The input text to analyze.
* @return double A score between -1.0 (negative) and 1.0 (positive).
*/
double analyze(std::string_view text) const;
/**
* @brief Tokenizes the input text into words.
*
* @param text The input text.
* @return std::vector<std::string> List of tokens.
*/
std::vector<std::string> tokenize(std::string_view text) const;
private:
std::map<std::string, double> lexicon;
void loadLexicon();
};
#endif // SENTIMENT_ANALYZER_HPP