docstr: Returns a map of each location and the starting indicies of all
  appearances of that location in the text.
docstr_tok: ["Returns","a","map","of","each","location","and","the","starting","indicies","of","all","appearances","of","that","location","in","the","text","."]
code: def _build_location_to_indicies_map(self, location_words, text):
      """Returns a map of each location and the starting indicies of all
      appearances of that location in the text."""
  
      location_to_indices = defaultdict(list)
      if len(location_words) == 0:
          return location_to_indices
  
      location_words.sort(
          # Sort by the number of words in the location
          key=lambda index_location_pair: index_location_pair[0][-1]
          - index_location_pair[0][0]
          + 1,
          reverse=True,
      )
      max_length = (
          location_words[0][0][-1] - location_words[0][0][0] + 1
      )
  
      for idx, location in location_words:
          words_in_location = idx[-1] - idx[0] + 1
          found = False
          location_start = idx[0]
  
          # Check each window of n words containing the original tagged location
          # for n from the max_length down to the original location length.
          # This prevents cases where the NER tagger misses a word in a location
          # (e.g. it does not tag "New" in "New York")
          for length in range(max_length, words_in_location, -1):
              for start in range(
                  location_start - length + words_in_location,
                  location_start + 1,
              ):
                  if start + length > len(text.words):
                      break
  
                  expanded_location = self._capitalize(
                      " ".join(text.words[start : start + length])
                  )
                  if expanded_location in location_to_indices:
                      location_to_indices[expanded_location].append(
                          start
                      )
                      found = True
                      break
  
              if found:
                  break
  
          if not found:
              location_to_indices[self._capitalize(location)].append(
                  idx[0]
              )
  
      return location_to_indices
  
file_path: TextAttack/textattack/transformations/word_swaps/word_swap_change_location.py
imports: from collections import defaultdict
  import more_itertools
  import numpy
  from textattack.shared.data import NAMED_ENTITIES
  from .word_swap import WordSwap
label_desc: Use image node_id 5 for calling the WordSwapChangeLocation obj's underlying member method code with example usage: obj._build_location_to_indicies_map(location_words, text) and returns: location_to_indices, location_to_indices