Generate functions for querying facts and opinions