Added a build_dictionary function to create a dictionary from a seq