Listing 9

std::size_t occurrences(const text & txt, const std::string & word)
{
  return txt.get<1>().count(word);
}