Files
privacore-open-source-searc…/Pops.h

37 lines
766 B
C
Raw Normal View History

2013-08-02 13:12:24 -07:00
// Matt Wells, copyright Aug 2005
2016-03-08 22:14:30 +01:00
#ifndef GB_POPS_H
#define GB_POPS_H
2013-08-02 13:12:24 -07:00
#define POPS_BUF_SIZE (10*1024)
// the max popularity score a word can have
#define MAX_POP 0x7fff
2016-05-23 16:53:54 +02:00
class Words;
2013-08-02 13:12:24 -07:00
// the popularity vector for the Words class, 1-1 with those words
class Pops {
2016-02-17 14:43:47 +01:00
public:
2013-08-02 13:12:24 -07:00
Pops();
~Pops();
// . set m_pops to the popularity of each word in "words"
// . m_pops[] is 1-1 with the words in "words"
// . must have computed the word ids (words->m_wordIds must be valid)
2016-05-23 16:53:54 +02:00
bool set ( const Words *words, int32_t a, int32_t b );
2013-08-02 13:12:24 -07:00
// from 0.0 to 1.0
2016-05-23 16:53:54 +02:00
float getNormalizedPop( int32_t i ) const {
2016-02-17 14:43:47 +01:00
return (float)m_pops[i] / (float)MAX_POP;
}
2013-08-02 13:12:24 -07:00
2016-02-17 14:43:47 +01:00
private:
2014-11-10 14:45:11 -08:00
int32_t *m_pops;
int32_t m_popsSize; // in bytes
2013-08-02 13:12:24 -07:00
char m_localBuf [ POPS_BUF_SIZE ];
};
2016-03-08 22:14:30 +01:00
#endif // GB_POPS_H