From 1d15f748200f093d869c6fcc38d6053903ff5062 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 25 Jan 2016 09:13:14 -0500 Subject: hashtags are now randomized --- kgramstats.h | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'kgramstats.h') diff --git a/kgramstats.h b/kgramstats.h index ca61df7..ff2fc66 100644 --- a/kgramstats.h +++ b/kgramstats.h @@ -7,19 +7,34 @@ #ifndef KGRAMSTATS_H #define KGRAMSTATS_H +enum tokentype { + tokentype_literal, + tokentype_hashtag +}; + struct token { + tokentype type; std::string canon; bool terminating; - token(std::string canon) : canon(canon), terminating(false) {} + token(std::string canon) : type(tokentype_literal), canon(canon), terminating(false) {} + token(tokentype type) : type(type), canon(""), terminating(false) {} bool operator<(const token& other) const { - if (canon == other.canon) + if (type != other.type) { - return !terminating && other.terminating; + return type < other.type; + } else if (type == tokentype_literal) + { + if (canon == other.canon) + { + return !terminating && other.terminating; + } else { + return canon < other.canon; + } } else { - return canon < other.canon; + return !terminating && other.terminating; } } }; @@ -94,6 +109,7 @@ private: std::map > stats; malaprop mstats; std::map > endings; + std::vector hashtags; }; void printKgram(kgram k); -- cgit 1.4.1