diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-01-25 09:13:14 -0500 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-01-25 09:13:14 -0500 |
commit | 1d15f748200f093d869c6fcc38d6053903ff5062 (patch) | |
tree | 3b980a35fa2c0ef2e206786ab40d3431fe8c2ec2 /kgramstats.h | |
parent | 5151a32192f3efdf3efb6c54f703a8f9ba83335a (diff) | |
download | rawr-ebooks-1d15f748200f093d869c6fcc38d6053903ff5062.tar.gz rawr-ebooks-1d15f748200f093d869c6fcc38d6053903ff5062.tar.bz2 rawr-ebooks-1d15f748200f093d869c6fcc38d6053903ff5062.zip |
hashtags are now randomized
Diffstat (limited to 'kgramstats.h')
-rw-r--r-- | kgramstats.h | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/kgramstats.h b/kgramstats.h index ca61df7..ff2fc66 100644 --- a/kgramstats.h +++ b/kgramstats.h | |||
@@ -7,19 +7,34 @@ | |||
7 | #ifndef KGRAMSTATS_H | 7 | #ifndef KGRAMSTATS_H |
8 | #define KGRAMSTATS_H | 8 | #define KGRAMSTATS_H |
9 | 9 | ||
10 | enum tokentype { | ||
11 | tokentype_literal, | ||
12 | tokentype_hashtag | ||
13 | }; | ||
14 | |||
10 | struct token { | 15 | struct token { |
16 | tokentype type; | ||
11 | std::string canon; | 17 | std::string canon; |
12 | bool terminating; | 18 | bool terminating; |
13 | 19 | ||
14 | token(std::string canon) : canon(canon), terminating(false) {} | 20 | token(std::string canon) : type(tokentype_literal), canon(canon), terminating(false) {} |
21 | token(tokentype type) : type(type), canon(""), terminating(false) {} | ||
15 | 22 | ||
16 | bool operator<(const token& other) const | 23 | bool operator<(const token& other) const |
17 | { | 24 | { |
18 | if (canon == other.canon) | 25 | if (type != other.type) |
19 | { | 26 | { |
20 | return !terminating && other.terminating; | 27 | return type < other.type; |
28 | } else if (type == tokentype_literal) | ||
29 | { | ||
30 | if (canon == other.canon) | ||
31 | { | ||
32 | return !terminating && other.terminating; | ||
33 | } else { | ||
34 | return canon < other.canon; | ||
35 | } | ||
21 | } else { | 36 | } else { |
22 | return canon < other.canon; | 37 | return !terminating && other.terminating; |
23 | } | 38 | } |
24 | } | 39 | } |
25 | }; | 40 | }; |
@@ -94,6 +109,7 @@ private: | |||
94 | std::map<kgram, std::map<int, token_data> > stats; | 109 | std::map<kgram, std::map<int, token_data> > stats; |
95 | malaprop mstats; | 110 | malaprop mstats; |
96 | std::map<token, std::map<int, termstats> > endings; | 111 | std::map<token, std::map<int, termstats> > endings; |
112 | std::vector<std::string> hashtags; | ||
97 | }; | 113 | }; |
98 | 114 | ||
99 | void printKgram(kgram k); | 115 | void printKgram(kgram k); |