You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
713 B

9 months ago
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 ))
for (w, c) in word_freqs:
print(w, '-', c)