'--logfile', dest='logfile', help=str.format( 'name of file to write log contents to (empty for stdout)'), default=None) (options, args) = parser.parse_args() if len(args) != 1 or (not options.entity_embf) or ( not options.ctx_embf) or (options.entity_defnf and not options.word_embf): parser.print_help() exit() (mentionf, ) = args return mentionf, options mentionf, options = _cli() log.start(logfile=options.logfile, stdout_also=True) if options.tab_separated: sep = '\t' else: sep = ' ' t_sub = log.startTimer('Reading entity embeddings from %s...' % options.entity_embf, newline=False) entity_embeds = pyemblib.read(options.entity_embf, separator=sep) log.stopTimer(t_sub, message='Read %d embeddings ({0:.2f}s)' % len(entity_embeds)) t_sub = log.startTimer('Reading context embeddings from %s...' % options.ctx_embf,
parser.add_option('--dataset', dest='dataset', help='analogy dataset to run on', type='choice', choices=datasets.aslist(), default=None) parser.add_option('--to-lower', dest='to_lower', action='store_true', default=False, help='lowercase all analogies') parser.add_option('-l', '--logfile', dest='logfile', help='name of file to write log contents to (empty for stdout)', default=None) (options, args) = parser.parse_args() if len(args) != 1 or not options.dataset: parser.print_help() exit() return args, options (vocabf,), options = _cli() log.start(logfile=options.logfile) config = configparser.ConfigParser() config.read(options.config) analogy_file = datasets.getpath(options.dataset, config, eval_mode.ALL_INFO) configlogger.writeConfig(log, settings=[ ('Config file', options.config), ('Dataset', options.dataset), ('Path to dataset', analogy_file), ('Lowercasing analogies', options.to_lower), ('Output vocab file', vocabf), ], title='Vocabulary extraction from analogy dataset') log.writeln('Reading %s analogies from %s...' % (options.dataset, analogy_file))
'%s -- A vs B' % ds) (at, at_size) = correlation(lbl_scores_1, gold_1, '%s -- A vs GOLD' % ds) (bt, bt_size) = correlation(lbl_scores_2, gold_2, '%s -- B vs GOLD' % ds) log.writeln("\n -- %s Agreement summary --" % ds) log.writeln(" |r_bt - r_at| = %f" % abs(at - bt)) log.writeln(" r_ab = %f (%d)" % (ab, ab_size)) log.writeln(" r_at = %f (%d)" % (at, at_size)) log.writeln(" r_bt = %f (%d)" % (bt, bt_size)) if __name__ == '__main__': def _cli(): import optparse parser = optparse.OptionParser(usage='Usage: %prog LOG1 LOG2') parser.add_option('-l', '--logfile', dest='logfile') (options, args) = parser.parse_args() if len(args) != 2: parser.print_help() exit() return args, options.logfile (f1, f2), logfile = _cli() log.start(logfile=logfile, stdout_also=True) log.writeln('A: %s' % f1) log.writeln('B: %s' % f2) getStatistics(f1, f2)