from collections import defaultdict, deque

class Personalization:

    def __init__(self):
        self.user_freq = defaultdict(int)
        self.recent = deque(maxlen=30)

    def learn(self, word):
        self.user_freq[word] += 1
        self.recent.append(word)

    def boost(self, word):
        score = 0
        if word in self.recent:
            score += 2
        score += self.user_freq[word]
        return score