def process_tokens(words, normalize_plurals=True):
<EOL>d = defaultdict(dict)<EOL>for word in words:<EOL><INDENT>word_lower = word.lower()<EOL>case_dict = d[word_lower]<EOL>case_dict[word] = case_dict.get(word, <NUM_LIT:0>) + <NUM_LIT:1><EOL><DEDENT>if normalize_plurals:<EOL><INDENT>merged_plurals = {}<EOL>for key in list(d.keys()):<EOL><INDENT>if key.endswith('<STR_LIT:s>') and not key.endswith("<STR_LIT>"):<EOL><INDENT>key_singular = key[:-<NUM_LIT:1>]<EOL>if key_singular in d:<EOL><INDENT>dict_plural = d[key]<EOL>dict_singular = d[key_singular]<EOL>for word, count in dict_plural.items():<EOL><INDENT>singular = word[:-<NUM_LIT:1>]<EOL>dict_singular[singular] = (<EOL>dict_singular.get(singular, <NUM_LIT:0>) + count)<EOL><DEDENT>merged_plurals[key] = key_singular<EOL>del d[key]<EOL><DEDENT><DEDENT><DEDENT><DEDENT>fused_cases = {}<EOL>standard_cases = {}<EOL>item1 = itemgetter(<NUM_LIT:1>)<EOL>for word_lower, case_dict in d.items():<EOL><INDENT>first = max(case_dict.items(), key=item1)[<NUM_LIT:0>]<EOL>fused_cases[first] = sum(case_dict.values())<EOL>standard_cases[word_lower] = first<EOL><DEDENT>if normalize_plurals:<EOL><INDENT>for plural, singular in merged_plurals.items():<EOL><INDENT>standard_cases[plural] = standard_cases[singular.lower()]<EOL><DEDENT><DEDENT>return fused_cases, standard_cases<EOL>
Normalize cases and remove plurals.

    Each word is represented by the most common case.
    If a word appears with an "s" on the end and without an "s" on the end,
    the version with "s" is assumed to be a plural and merged with the
    version without "s" (except if the word ends with "ss").

    Parameters
    ----------
    words : iterable of strings
        Words to count.

    normalize_plurals : bool, default=True
        Whether to try and detect plurals and remove trailing "s".

    Returns
    -------
    counts : dict from string to int
        Counts for each unique word, with cases represented by the most common
        case, and plurals removed.

    standard_forms : dict from string to string
        For each lower-case word the standard capitalization.