def match_alphabet(self, pattern):
    """Initialise the alphabet for the Bitap algorithm.

    Args:
      pattern: The text to encode.

    Returns:
      Hash of character locations.
    """
    s = {}
    for char in pattern:
      s[char] = 0
    for i in xrange(len(pattern)):
      s[pattern[i]] |= 1 << (len(pattern) - i - 1)
    return s
Initialise the alphabet for the Bitap algorithm.

    Args:
      pattern: The text to encode.

    Returns:
      Hash of character locations.