def inner_product(L1, L2):
  """
  Take the inner product of the frequency maps.

  """
  result = 0.
  for word1, count1 in L1:
    for word2, count2 in L2:
      if word1 == word2:
        result += count1 * count2
  return result