from statistics import mean import choices.wordnet.wn_thai as wnth import ast wn = wnth.wordnet_thai() class word_item: def __init__(self, *args, **kwargs): if len(args) > 0: self.word = args[0] if len(args) == 1: self.eng_word, self.index = wn.get_general_info(self.word) self.hypernym_index = hypernym_index = None elif len(args) == 4: (eng_word, index, hypernym_index) = args[1:] self.eng_word = eng_word self.index = index self.hypernym_index = hypernym_index elif "from_str" in kwargs: attributes = ast.literal_eval(kwargs["from_str"]) for key in attributes: setattr(self, key, attributes[key]) self.evals = [] # self.concord = self.prepare_cooccur() def add_evaluation(self, score): if score < 1: self.evals.append(0) else: self.evals.append(score)
import choices.choice_ranker as chrank import display_results as display import ast import sys import pickle from os import listdir from os.path import isfile, join import csv import choices.wordnet.wn_tree as wn_tree ss = _ss.sentence_segment() qg = _qg.question_generator() wnth = _wnth.wordnet_thai() chg = None qr = None choice_rank = None def read_custom_dict(dictdir): files = [join(dictdir, f) for f in listdir(dictdir) if isfile(join(dictdir, f))] custom_dict = dict() for filename in files: if filename[-4:] == ".csv": with open(filename, encoding="utf-8") as csvfile: reader = csv.reader(csvfile) next(reader, None) for row in reader: edited_info = [data if data != "" else None for data in row]