about summary refs log tree commit diff stats
path: root/malaprop.h
blob: 91a18eb8afc0806b6c8798bbfaa85dc3534c9607 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef MALAPROP_H_8F382336
#define MALAPROP_H_8F382336

#include <string>
#include <map>
#include <set>

class malaprop
{
public:
  void addWord(std::string word);
  void stats();
  std::string alternate(std::string word);
  
private:
  struct soundex {
    char prefix;
    int code;
    
    bool operator<(const soundex& other) const
    {
      return (prefix < other.prefix) || (code < other.code);
    }
  };
  
  std::map<soundex, std::set<std::string> > dict;
  
  soundex soundify(std::string l);
};

#endif /* end of include guard: MALAPROP_H_8F382336 */