code: def _score_ngram_candidates(
      candidates: list[tuple[Token, ...]],
      ngram_freqs: dict[str, int],
      word_scores: dict[int, float],
      term_scores: dict[str, float],
      seen_candidates: set[str],
      normalize: Optional[str],
  ):
      attr_name = _get_attr_name(normalize, False)
      attr_name_str = _get_attr_name(normalize, True)
      for ngram in candidates:
          ngtxt = " ".join(
              getattr(word, attr_name_str) for word in ngram
          )
          if ngtxt in seen_candidates:
              continue
          else:
              seen_candidates.add(ngtxt)
          ngram_word_scores = [
              word_scores[getattr(word, attr_name)] for word in ngram
          ]
          # multiply individual word scores together in the numerator
          numerator = functools.reduce(
              operator.mul, ngram_word_scores, 1.0
          )
          # NOTE: here i've modified the YAKE algorithm to put less emphasis on term freq
          # denominator = ngram_freqs[ngtxt] * (1.0 + sum(ngram_word_scores))
          denominator = math.log2(1 + ngram_freqs[ngtxt]) * (
              1.0 + sum(ngram_word_scores)
          )
          term_scores[ngtxt] = numerator / denominator
  
file_path: textacy/src/textacy/extract/keyterms/yake.py
imports: from __future__ import annotations
  import collections
  import functools
  import math
  import operator
  import statistics
  from typing import Collection, Iterable, Optional
  from cytoolz import itertoolz
  from spacy.tokens import Doc, Token
  from ...None import errors, utils
  from ..None import utils
label_desc: Use image node_id 7 for calling a global function with example usage: _score_ngram_candidates(candidates, ngram_freqs, word_scores, term_scores, seen_candidates, normalize) without return types