summaryrefslogtreecommitdiff
path: root/src/freqdict.h
blob: c9bb4c422b2b341894134aef04a06df3e19eaecc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#ifndef _FREQDICT_H_
#define _FREQDICT_H_

#include <map>
#include <string>

class FreqDict {
 public:
  void load(const std::string& fname);
  float frequency(const std::string& word) const {
    std::map<std::string,float>::const_iterator i = counts_.find(word);
    if (i == counts_.end()) return 0;
    return i->second;
  }
 private:
  std::map<std::string, float> counts_;
};

#endif