generated from trianta/cpp-unity-template
46 lines
1.0 KiB
C++
46 lines
1.0 KiB
C++
#ifndef FILTER_HPP
|
|
#define FILTER_HPP
|
|
|
|
#include <map>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
struct ReportData {
|
|
double spam_precision;
|
|
double spam_recall;
|
|
double ham_precision;
|
|
double ham_recall;
|
|
double spam_f_score;
|
|
double ham_f_score;
|
|
double accuracy;
|
|
};
|
|
|
|
struct SMSMessage {
|
|
SMSMessage(bool given_type, std::string given_message);
|
|
bool is_ham;
|
|
std::string message;
|
|
bool is_ham_filter;
|
|
};
|
|
|
|
class SMSMessageFilter {
|
|
public:
|
|
SMSMessageFilter(void) = default;
|
|
~SMSMessageFilter(void) = default;
|
|
void GenerateProbability(std::string file_name);
|
|
void Prepare(std::string file_name);
|
|
void Filter(void);
|
|
void Report(void);
|
|
|
|
private:
|
|
double sentence_probability_ham = 0.5; // Spam is 1 - sentence_probability_ham
|
|
std::map<std::string, double> probability_dictionary;
|
|
std::vector<SMSMessage> filtered_messages;
|
|
ReportData GenerateReport(void);
|
|
void PrintReport(ReportData report);
|
|
|
|
};
|
|
|
|
std::string SanitizeToken(std::string token);
|
|
|
|
#endif // !FILTER_HPP
|