From d62c340f1841c6fc46968643fab63841083aec6f Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sat, 13 Feb 2016 23:43:13 -0500 Subject: Fixed issue where queries with both the wildcard token and a terminating token would reset the prefix --- kgramstats.cpp | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'kgramstats.cpp') diff --git a/kgramstats.cpp b/kgramstats.cpp index ac694f3..f788cb1 100644 --- a/kgramstats.cpp +++ b/kgramstats.cpp @@ -344,21 +344,12 @@ kgramstats::kgramstats(std::string corpus, int maxK) td.titlecase++; } - kgram term_prefix; - bool changed = false; - std::transform(prefix.begin(), prefix.end(), std::back_inserter(term_prefix), [&] (query& q) { - if (q.tok.suffix == suffixtype::terminating) - { - changed = true; - - return wildcardQuery; - } else { - return q; - } - }); - - if (changed) + if (std::begin(prefix)->tok.suffix == suffixtype::terminating) { + kgram term_prefix(prefix); + term_prefix.pop_front(); + term_prefix.push_front(wildcardQuery); + if (tstats[term_prefix].count(f) == 0) { tstats[term_prefix].emplace(f, f); -- cgit 1.4.1