25 #ifndef PRESAGE_ARPAPREDICTOR 26 #define PRESAGE_ARPAPREDICTOR 29 #include "../core/logger.h" 30 #include "../core/progress.h" 31 #include "../core/dispatcher.h" 40 bool operator() (
const float& f1,
const float& f2 )
const {
49 ARPAData(
float lp,
float la) : logProb(lp), logAlfa(la) {};
57 TrigramKey(
int wd1,
int wd2,
int wd3) : key1(wd1), key2(wd2), key3(wd3) {};
64 if(key1 == right.
key1)
65 if(key2 < right.
key2 )
68 if(key1 == right.
key1 && key2 == right.
key2)
77 return (key1 == right.
key1 && key2 == right.
key2 && key3 == right.
key3 );
87 BigramKey(
int wd1,
int wd2) : key1(wd1), key2(wd2) {};
94 if(key1 == right.
key1)
95 if(key2 < right.
key2 )
103 return (key1 == right.
key1 && key2 == right.
key2);
118 virtual Prediction predict(
const size_t size,
const char** filter)
const;
120 virtual void learn(
const std::vector<std::string>& change);
122 virtual void update (
const Observable* variable);
124 void set_vocab_filename (
const std::string& value);
125 void set_arpa_filename (
const std::string& value);
126 void set_timeout (
const std::string& value);
145 void loadVocabulary();
146 void createARPATable();
147 bool matchesPrefixAndFilter(std::string , std::string ,
const char** )
const;
149 void addUnigram(std::string);
150 void addBigram(std::string);
151 void addTrigram(std::string);
153 inline float computeTrigramBackoff(
int,
int,
int)
const;
154 inline float computeBigramBackoff(
int,
int)
const;
171 #endif // PRESAGE_ARPAPREDICTOR
bool operator()(const float &f1, const float &f2) const
std::map< TrigramKey, float > trigramMap
BigramKey(int wd1, int wd2)
ProgressBar< char > * unigramProg
Dispatcher< ARPAPredictor > dispatcher
bool operator<(const BigramKey &right) const
ProgressBar< char > * trigramProg
bool operator==(const TrigramKey &right) const
ProgressBar< char > * bigramProg
std::map< std::string, int > vocabCode
bool operator<(const TrigramKey &right) const
std::map< int, std::string > vocabDecode
TrigramKey(int wd1, int wd2, int wd3)
Tracks user interaction and context.
std::string VOCABFILENAME
std::string vocabFilename
std::map< int, ARPAData > unigramMap
std::map< BigramKey, ARPAData > bigramMap
bool operator==(const TrigramKey &right) const