-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTrigram.h
42 lines (33 loc) · 929 Bytes
/
Trigram.h
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
32
33
34
35
36
37
38
39
40
41
42
////////////////////////////////////////////////////////////////////////////////
///
/// @file Trigram.h
/// @brief Brief description here.
///
#ifndef TRIGRAM_H
#define TRIGRAM_H
#include <map>
#include <vector>
#include <string>
#include <boost/tokenizer.hpp>
typedef std::pair<std::string, std::string> word_pair;
typedef std::vector<std::string> word_vector;
typedef std::map<word_pair, word_vector> tuple_map;
typedef boost::char_separator<char> separator;
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
class Randomizer
{
public:
virtual int Random(int modulo) = 0;
};
class Trigram
{
public:
Trigram(const std::string& text, Randomizer* randomizer = 0);
word_vector operator[](const word_pair& wordPair);
std::string generateSentence(int maxLength = 20);
private:
tuple_map tuples;
Randomizer* randomizer_;
word_pair getStartingWordPair();
};
#endif // TRIGRAM_H