def protect_shorthand(text, split_locations):
word_matches = list(re.finditer(word_with_period, text))<EOL>total_words = len(word_matches)<EOL>for i, match in enumerate(word_matches):<EOL><INDENT>match_start = match.start()<EOL>match_end = match.end()<EOL>for char_pos in range(match_start, match_end):<EOL><INDENT>if split_locations[char_pos] == SHOULD_SPLIT and match_end - char_pos > <NUM_LIT:1>:<EOL><INDENT>match_start = char_pos<EOL><DEDENT><DEDENT>word = text[match_start:match_end]<EOL>if not word.endswith('<STR_LIT:.>'):<EOL><INDENT>if (not word[<NUM_LIT:0>].isdigit() and<EOL>split_locations[match_start] == UNDECIDED):<EOL><INDENT>split_locations[match_start] = SHOULD_SPLIT<EOL><DEDENT>continue<EOL><DEDENT>period_pos = match_end - <NUM_LIT:1><EOL>word_is_in_abbr = word[:-<NUM_LIT:1>].lower() in ABBR<EOL>is_abbr_like = (<EOL>word_is_in_abbr or<EOL>one_letter_long_or_repeating.match(word[:-<NUM_LIT:1>]) is not None<EOL>)<EOL>is_digit = False if is_abbr_like else word[:-<NUM_LIT:1>].isdigit()<EOL>is_last_word = i == (total_words - <NUM_LIT:1>)<EOL>is_ending = is_last_word and (match_end == len(text) or text[match_end:].isspace())<EOL>is_not_ending = not is_ending<EOL>abbreviation_and_not_end = (<EOL>len(word) > <NUM_LIT:1> and<EOL>is_abbr_like and<EOL>is_not_ending<EOL>)<EOL>if abbreviation_and_not_end and (<EOL>(not is_last_word and word_matches[i+<NUM_LIT:1>].group(<NUM_LIT:0>)[<NUM_LIT:0>].islower()) or<EOL>(not is_last_word and word_matches[i+<NUM_LIT:1>].group(<NUM_LIT:0>) in PUNCT_SYMBOLS) or<EOL>word[<NUM_LIT:0>].isupper() or<EOL>word_is_in_abbr or<EOL>len(word) == <NUM_LIT:2>):<EOL><INDENT>if split_locations[period_pos] == SHOULD_SPLIT and period_pos + <NUM_LIT:1> < len(split_locations):<EOL><INDENT>split_locations[period_pos + <NUM_LIT:1>] = SHOULD_SPLIT<EOL><DEDENT>split_locations[period_pos] = SHOULD_NOT_SPLIT<EOL><DEDENT>elif (is_digit and<EOL>len(word[:-<NUM_LIT:1>]) <= <NUM_LIT:2> and<EOL>not is_last_word and<EOL>word_matches[i+<NUM_LIT:1>].group(<NUM_LIT:0>).lower() in MONTHS):<EOL><INDENT>if split_locations[period_pos] == SHOULD_SPLIT and period_pos + <NUM_LIT:1> < len(split_locations):<EOL><INDENT>split_locations[period_pos + <NUM_LIT:1>] = SHOULD_SPLIT<EOL><DEDENT>split_locations[period_pos] = SHOULD_NOT_SPLIT<EOL><DEDENT>elif split_locations[period_pos] == UNDECIDED:<EOL><INDENT>split_locations[period_pos] = SHOULD_SPLIT<EOL><DEDENT><DEDENT>
Annotate locations in a string that contain
periods as being true periods or periods
that are a part of shorthand (and thus should
not be treated as punctuation marks).

Arguments:
----------
    text : str
    split_locations : list<int>, same length as text.