def eval(): print('Loading association matrix') matrix = matrix_dict.Matrix_Dict() matrix.read_matrix_from_file(MATRIX_FILE) print('Evaluating') scorer.evaluate_kbest_MeanReciprocalRank(matrix, corpora.GAME_SET_100_FILE, EVAL_WORD_GAME100_FILE)
def build_and_eval(): utility.make_dir(OUTPUT_DIR) print('Building lexicon') poli_lexicon = list(lexicon.loadLexiconFromFile(corpora.DIZ_POLI_WORD_SORTED_FILE)) sost_lexicon = list(lexicon.loadLexiconFromFile(corpora.DIZIONARIO_SOSTANTIVI_AUGMENTED_PAISA_FILE)) agg_lexicon = list(lexicon.loadLexiconFromFile(corpora.DIZIONARIO_AGGETTIVI_AUGMENTED_PAISA_FILE)) lex_set = set(poli_lexicon+sost_lexicon+agg_lexicon) lex_solution_set = set(sost_lexicon+agg_lexicon) lexicon.printLexiconToFile(lex_set, LEX_FREQ_FILE) lexicon.printLexiconToFile(lex_solution_set, SOLUTION_LEX_FREQ_FILE) print('Computing coverage') scorer.computeCoverageOfGameWordLex(lex_set, lex_solution_set, corpora.GAME_SET_100_FILE, COVERAGE_WORD_GAME100_FILE) print('Building association matrix') matrix = matrix_dict.Matrix_Dict(lex_set, lex_solution_set) matrix.add_patterns_from_corpus(corpora.PAISA_RAW_INFO) matrix.compute_association_scores() matrix.write_matrix_to_file(MATRIX_FILE) print('Eval') scorer.evaluate_kbest_MeanReciprocalRank(matrix, corpora.GAME_SET_100_FILE, EVAL_WORD_GAME100_FILE) scorer.evaluate_kbest_MeanReciprocalRank(matrix, corpora.NLP4FUN_DEV_TSV_v2_tv_FILE, EVAL_NLP4FUN_DEV_TV_FILE) scorer.evaluate_kbest_MeanReciprocalRank(matrix, corpora.NLP4FUN_DEV_TSV_v2_bg_FILE, EVAL_NLP4FUN_DEV_BG_FILE)
def build_and_eval(): utility.make_dir(OUTPUT_DIR) print('Building lexicon') lex_set = lexicon.loadLexiconFromFile(corpora.DIZ_POLI_WORD_SORTED_FILE) lexicon_freq = {w: 1 for w in lex_set} #lex_solution_set = lexicon.loadLexiconFromFile(corpora.DIZIONARIO_BASE_SOSTANTIVI_FILE) print('Lex size: {}'.format(len(lex_set))) lexicon.printLexFreqToFile(lexicon_freq, LEX_FREQ_FILE) print('Computing coverage') scorer.computeCoverageOfGameWordLex(lexicon_freq, corpora.GAME_SET_100_FILE, COVERAGE_WORD_GAME100_FILE) print('Building association matrix') matrix = matrix_dict.Matrix_Dict(lex_set=lex_set) # lex_solution_set matrix.add_patterns_from_corpus(corpora.PAISA_RAW_INFO) matrix.add_patterns_from_corpus(corpora.DE_MAURO_POLIREMATICHE_INFO, weight=DE_MAURO_WEIGHT) corpora.addBigramFromPolirematicheInMatrix(matrix, DE_MAURO_WEIGHT) matrix.compute_association_scores() matrix.write_matrix_to_file(MATRIX_FILE) print('Eval') scorer.evaluate_kbest_MeanReciprocalRank(matrix, corpora.GAME_SET_100_FILE, EVAL_WORD_GAME100_FILE)
def interactive_solver(): print('Loading association matrix') matrix = matrix_dict.Matrix_Dict() matrix.read_matrix_from_file(MATRIX_FILE) scorer.interactive_solver(matrix)