def load_lm_model(lm_fname, order=2): """ function to load language model """ lm_model=srilm.initLM(order) srilm.readLM(lm_model,lm_fname) return lm_model
def __init__(self, m, filename): """use srilm language model from filename""" self.m = m #order self.model = srilm.initLM(self.m) success = srilm.readLM(self.model, filename) if not success: print('LM load error') sys.exit(1)
def __init__(self, model_path, order=2): self.lm_path = model_path self.order = order self.history = [] self.EOS_ID = 1 self.history_len = order - 1 self.lm = initLM(order) readLM(self.lm, self.lm_path) self.vocab_size = howManyNgrams(self.lm, 1)
def __init__(self, model_path, order=2): self.lm_path = model_path self.order = order self.history = [] self.EOS_ID = 1 self.history_len = order - 1 print u'Initialize LM with order {}'.format(order) self.lm = initLM(order) readLM(self.lm, self.lm_path) self.vocab_size = howManyNgrams(self.lm, 1)
def __init__(self, path, ngram_order): """Creates a new n-gram language model predictor. Args: path (string): Path to the ARPA language model file ngram_order (int): Order of the language model Raises: NameError. If srilm-swig is not installed """ super(SRILMPredictor, self).__init__() self.history_len = ngram_order - 1 self.lm = initLM(ngram_order) readLM(self.lm, path)
def __init__(self, path, ngram_order): """Creates a new n-gram language model predictor. Args: path (string): Path to the ARPA language model file ngram_order (int): Order of the language model Raises: NameError. If srilm-swig is not installed """ super(SRILMPredictor, self).__init__() self.history_len = ngram_order-1 self.lm = initLM(ngram_order) readLM(self.lm, path)
def __init__(self, path, ngram_order, convert_to_ln=False): """Creates a new n-gram language model predictor. Args: path (string): Path to the ARPA language model file ngram_order (int): Order of the language model Raises: NameError. If srilm-swig is not installed """ super(SRILMPredictor, self).__init__() self.history_len = ngram_order-1 self.lm = initLM(ngram_order) readLM(self.lm, path) self.vocab_size = howManyNgrams(self.lm, 1) self.convert_to_ln = convert_to_ln if convert_to_ln: import logging logging.info("SRILM: Convert log scores to ln scores")
def __init__(self, path, ngram_order, convert_to_ln=False): """Creates a new n-gram language model predictor. Args: path (string): Path to the ARPA language model file ngram_order (int): Order of the language model convert_to_ln (bool): Whether to convert ld scores to ln. Raises: NameError. If srilm-swig is not installed """ super(SRILMPredictor, self).__init__() self.history_len = ngram_order-1 self.lm = initLM(ngram_order) readLM(self.lm, path) self.vocab_size = howManyNgrams(self.lm, 1) self.convert_to_ln = convert_to_ln if convert_to_ln: import logging logging.info("SRILM: Convert log scores to ln scores")
def _init_lm(self, lm_fname): self.lm_model = srilm.initLM(2) srilm.readLM(self.lm_model, lm_fname)
def _init_lm(self,lm_fname): self.lm_model=srilm.initLM(2) srilm.readLM(self.lm_model,lm_fname)