- Main Page
- Namespaces
- Classes
- Files

# proto/Source/evaluation.h

Go to the documentation of this file.

    00001
    00022 #ifndef _EVALUATION_H
    00023 #define _EVALUATION_H
    00024
    00025 // We work with N-grams here.
    00026 #include "ngrams.h"
    00027
    00028 namespace ace {
    00029
    00030 // Forward declaration (class declares some friend functions).
    00031 class EvaluationTables;
    00032
    00035 namespace eval {
    00038     double chi_square_test(const EvaluationTables& tables);
    00041     double log_likelihood_ratio(const EvaluationTables& tables);
    00044     double mutual_information(const EvaluationTables& tables);
    00047     double pearsons_coefficient(const EvaluationTables& tables);
    00050     double t_test(const EvaluationTables& tables);
    00053     double z_score(const EvaluationTables& tables);
    00054
    00055 } // namespace eval
    00056
    00059 typedef std::vector<double> exp_table_t;
    00060
    00063 class EvaluationTables {
    00066     static std::vector<std::vector<size_t> > _bits_for_cont_table;
    00069     static std::vector<std::vector<size_t> > _bits_for_inv_table;
    00070
    00074     const freq_table_t _freq;
    00078     freq_table_t _cont;
    00082     freq_table_t _inv;
    00085     exp_table_t _exp;
    00086
    00087 public:
    00091     EvaluationTables(const freq_table_t frequencies);
    00095     static void init(void);
    00098     inline const freq_table_t& frequency(void) const { return _freq; }
    00101     inline const freq_table_t& contigency(void) const { return _cont; }
    00104     inline const freq_table_t& inverted_frequency(void) const { return _inv; }
    00107     inline const exp_table_t& expected_frequency(void) const { return _exp; }
    00110     inline size_t size(void) const { return _freq.size(); }
    00111
    00114     friend double eval::chi_square_test(const EvaluationTables& tables);
    00117     friend double eval::log_likelihood_ratio(const EvaluationTables& tables);
    00120     friend double eval::mutual_information(const EvaluationTables& tables);
    00123     friend double eval::pearsons_coefficient(const EvaluationTables& tables);
    00126     friend double eval::t_test(const EvaluationTables& tables);
    00129     friend double eval::z_score(const EvaluationTables& tables);
    00130 };
    00131
    00132 } // namespace ace
    00133
    00134 #endif