我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用util.load_config()。
def __init__(self, config_file): """Constructor""" # Load options util.load_config(self, config_file) # Set up the collection of verses self.verses = load_verses(self.general.output_file) self.n_verses = len(self.verses) # Store the verses by rhyme self.rhymes = defaultdict(lambda: set()) for i, verse in enumerate(self.verses): self.rhymes[poetry.verse_rhyme(verse)].add(i) # Total number of rhymes self.n_rhymes = len(self.rhymes) for k, v in self.rhymes.items(): self.rhymes[k] = list(v) # Probability of picking a rhyme # This probability is proportional to the number of verses for each rhyme. # In particular, for rhymes with only one verse, the probability is set to 0 self.p_rhymes = {r: (len(v) - 1) for r, v in self.rhymes.items()} self.names_rhymes, self.p_rhymes = zip(*self.p_rhymes.items()) self.p_rhymes = np.asarray(self.p_rhymes, dtype=float) self.p_rhymes /= self.p_rhymes.sum() # Title generator self.tg = title.get_title_generator(self.title)
def main(models, source_file, nbest_file, saveto, b=80, normalize=False, verbose=False, alignweights=False): # load model model_options options = [] for model in models: options.append(load_config(model)) fill_options(options[-1]) rescore_model(source_file, nbest_file, saveto, models, options, b, normalize, verbose, alignweights)
def __init__(self, config_file): """Init from yaml""" self.config_file = config_file # Load from yaml config file util.load_config(self, config_file) # Initialize other relevant variables self.n_pentameters = 0 self.n_length_removed = 0 self.n_pentameters_epoch = 0 self.last_tweet = 0 self.last_quatrain_tweet = 0 self.start = time.time() # Initialize reddit self.init_reddit()
def main(source_file, target_file, output_file, scorer_settings): # load model model_options options = [] for model in scorer_settings.models: options.append(load_config(model)) fill_options(options[-1]) rescore_model(source_file, target_file, output_file, scorer_settings, options)
def _load_model_options(self): """ Loads config options for each model. """ options = [] for model in self._models: m = load_config(model) if not 'concatenate_lm_decoder' in m: m['concatenate_lm_decoder'] = False options.append(m) # backward compatibility fill_options(options[-1]) self._options = options
def main(source_file, nbest_file, output_file, rescorer_settings): # load model model_options options = [] for model in rescorer_settings.models: options.append(load_config(model)) fill_options(options[-1]) rescore_model(source_file, nbest_file, output_file, rescorer_settings, options)
def main(args): paser = argparse.ArgumentParser() paser.add_argument('-c', '--conf', help='path to the config file') args = paser.parse_args() Config = load_config(args.conf) solve(Config)