(
    doc: Doc, normalize: Optional[str], stop_words: Set[str], window_size: int,
)
return word_occ_vals
Get base values for each individual occurrence of a word, to be aggregated
    and combined into a per-word score.
Get base values for each individual occurrence of a word, to be aggregated
    and combined into a per-word score.
Get base values for each individual occurrence of a word to be aggregated and combined into a per - word score .
def _get_per_word_occurrence_values(
    doc: Doc, normalize: Optional[str], stop_words: Set[str], window_size: int,
) -> Dict[int, Dict[str, list]]:
    """
    Get base values for each individual occurrence of a word, to be aggregated
    and combined into a per-word score.
    """
    word_occ_vals = collections.defaultdict(lambda: collections.defaultdict(list))

    def _is_upper_cased(tok):
        return tok.is_upper or (tok.is_title and not tok.is_sent_start)

    attr_name = _get_attr_name(normalize, False)
    padding = [None] * window_size
    for sent_idx, sent in enumerate(doc.sents):
        sent_padded = itertoolz.concatv(padding, sent, padding)
        for window in itertoolz.sliding_window(1 + (2 * window_size), sent_padded):
            lwords, word, rwords = (
                window[:window_size],
                window[window_size],
                window[window_size + 1 :],
            )
            w_id = getattr(word, attr_name)
            if word.is_stop:
                stop_words.add(w_id)
            word_occ_vals[w_id]["is_uc"].append(_is_upper_cased(word))
            word_occ_vals[w_id]["sent_idx"].append(sent_idx)
            word_occ_vals[w_id]["l_context"].extend(
                getattr(w, attr_name)
                for w in lwords
                if not (w is None or w.is_punct or w.is_space)
            )
            word_occ_vals[w_id]["r_context"].extend(
                getattr(w, attr_name)
                for w in rwords
                if not (w is None or w.is_punct or w.is_space)
            )
    return word_occ_vals
def _get_per_word_occurrence_values ( doc : Doc , normalize : Optional [ str ] , stop_words : Set [ str ] , window_size : int , ) -> Dict [ int , Dict [ str , list ] ] : word_occ_vals = collections . defaultdict ( lambda : collections . defaultdict ( list ) ) def _is_upper_cased ( tok ) : return tok . is_upper or ( tok . is_title and not tok . is_sent_start ) attr_name = _get_attr_name ( normalize , False ) padding = [ None ] * window_size for sent_idx , sent in enumerate ( doc . sents ) : sent_padded = itertoolz . concatv ( padding , sent , padding ) for window in itertoolz . sliding_window ( 1 + ( 2 * window_size ) , sent_padded ) : lwords , word , rwords = ( window [ : window_size ] , window [ window_size ] , window [ window_size + 1 : ] , ) w_id = getattr ( word , attr_name ) if word . is_stop : stop_words . add ( w_id ) word_occ_vals [ w_id ] [ "is_uc" ] . append ( _is_upper_cased ( word ) ) word_occ_vals [ w_id ] [ "sent_idx" ] . append ( sent_idx ) word_occ_vals [ w_id ] [ "l_context" ] . extend ( getattr ( w , attr_name ) for w in lwords if not ( w is None or w . is_punct or w . is_space ) ) word_occ_vals [ w_id ] [ "r_context" ] . extend ( getattr ( w , attr_name ) for w in rwords if not ( w is None or w . is_punct or w . is_space ) ) return word_occ_vals