import configparser, importlib.machinery from cppy.cp_util import * def load_plugins(): config = configparser.ConfigParser() script_dir = os.path.dirname(os.path.abspath(__file__)) os.chdir(script_dir) config.read("config.ini") words_plugin = config.get("Plugins", "words") frequencies_plugin = config.get("Plugins", "frequencies") global tfwords, tffreqs tfwords = importlib.machinery.SourcelessFileLoader('tfwords', words_plugin).load_module() tffreqs = importlib.machinery.SourcelessFileLoader('tffreqs', frequencies_plugin).load_module() load_plugins() word_freqs = tffreqs.top25(tfwords.extract_words( testfilepath )) print_word_freqs(word_freqs)