def score_word(self, word: str) -> float:
    """Scores a word as the sum of its n-letter sequences."""
    max_n = min(len(word), self._ngram_size)
    chars = ["<s>"] + list(word) + ["</s>"]
    score = 0
    for i in range(1, len(word)):
      context_start = max(0, i - max_n + 1)
      context = chars[context_start:i]
      new_score = self._model.logscore(chars[i], context)
      score += new_score

    return score
Scores a word as the sum of its n-letter sequences.
language/wino_dict/create_new_words.py