def _get_initial_hypos(self): """Get the list of initial ``PartialHypothesis``. """ self.cur_fst = load_fst( utils.get_path(self.fst_path, self.current_sen_id + 1)) init_hypo = PartialHypothesis(self.get_predictor_states()) init_hypo.fst_node = self._find_start_node() return [init_hypo]
def initialize(self, src_sentence): """Loads n-gram posteriors and resets history. Args: src_sentence (list): not used """ self._load_posteriors(utils.get_path(self.path, self.current_sen_id+1)) self.cur_history = [utils.GO_ID] self.discounts = SimpleTrie()
def initialize(self, src_sentence): """Loads the FST from the file system and consumes the start of sentence symbol. Args: src_sentence (list): Not used """ self.cur_fst = load_fst( utils.get_path(self.fst_path, self.current_sen_id + 1)) self.cur_nodes = [] if self.cur_fst: self.cur_nodes = self._follow_eps({self.cur_fst.start(): 0.0}) self.consume(utils.GO_ID) if not self.cur_nodes: logging.warn("The lattice for sentence %d does not contain any " "valid path. Please double-check that the lattice " "is not empty and that paths start with the begin-of-" "sentence symbol." % (self.current_sen_id + 1))
def initialize(self, src_sentence): """Loads the FST from the file system and consumes the start of sentence symbol. Args: src_sentence (list): Not used """ self.cur_fst = load_fst(utils.get_path(self.fst_path, self.current_sen_id+1)) self.cur_nodes = [] if self.cur_fst: self.cur_nodes = self._follow_eps({self.cur_fst.start(): 0.0}) self.consume(utils.GO_ID) if not self.cur_nodes: logging.warn("The lattice for sentence %d does not contain any " "valid path. Please double-check that the lattice " "is not empty and that paths start with the begin-of-" "sentence symbol." % (self.current_sen_id+1))
def initialize(self, src_sentence): """Loads the FST from the file system and consumes the start of sentence symbol. Args: src_sentence (list): Not used """ self.cur_fst = load_fst(utils.get_path(self.fst_path, self.current_sen_id+1)) self.cur_node = self.cur_fst.start() if self.cur_fst else None self.bos_score = self.consume(utils.GO_ID) if not self.bos_score: # Override None self.bos_score = 0.0 if self.cur_node is None: logging.warn("The lattice for sentence %d does not contain any " "valid path. Please double-check that the lattice " "is not empty and that paths contain the begin-of-" "sentence symbol %d. If you are using a different " "begin-of-sentence symbol, double-check --indexing_" "scheme." % (self.current_sen_id+1, utils.GO_ID))
def initialize(self, src_sentence): """Loads the FST from the file system and consumes the start of sentence symbol. Args: src_sentence (list): Not used """ self.cur_fst = load_fst( utils.get_path(self.fst_path, self.current_sen_id + 1)) self.cur_node = self.cur_fst.start() if self.cur_fst else None self.bos_score = self.consume(utils.GO_ID) if not self.bos_score: # Override None self.bos_score = 0.0 if self.cur_node is None: logging.warn("The lattice for sentence %d does not contain any " "valid path. Please double-check that the lattice " "is not empty and that paths the begin-of-" "sentence symbol %d. If you are using a different " "begin-of-sentence symbol, double-check --indexing_" "scheme." % (self.current_sen_id + 1, utils.GO_ID))