7380900edb073add959fc9cf4b67f93f0dc7a5c8,theanolm/scoring/rescoredlattice.py,RescoredLattice,__init__,#RescoredLattice#Any#Any#Any#Any#,65

Before Change


                word = vocabulary.id_to_word[word_id]
            else:
                word = word_id
                logging.debug("Out-of-vocabulary word in lattice: %s", word)

            // Find the incoming link that corresponds to the token that was kept
            // during recombination.
            try:

After Change


            self.links.append(link)

        // Add recombined tokens.
        oov_words = set()
        for token, new_history, nn_lm_logprob in reversed(recomb_tokens):
            assert new_history[-1] == token.history[-1]
            word_id = token.history[-1]
            if isinstance(word_id, int):
                word = vocabulary.id_to_word[word_id]
            else:
                word = word_id
                oov_words.add(word)

            // Find the incoming link that corresponds to the token that was kept
            // during recombination.
            try:
                recomb_from_node = follow_word_ids(new_history[:-1], False)
            except NodeNotFoundError:
                continue
            // Our new lattice doesn"t contain null links, so word_to_link maps
            // never skip nodes.
            if word not in recomb_from_node.word_to_link:
                continue
            recomb_link = recomb_from_node.word_to_link[word]

            // Add a link from the previous word in the token history to the node
            // that was kept during recombination. The difference in LM log
            // probability can be computed from the token (path) NNLM log
            // probabilities.
            from_node = follow_word_ids(token.history[:-1])
            lm_logprob_diff = token.nn_lm_logprob - nn_lm_logprob
            new_link = self.Link(from_node, recomb_link.end_node, word,
                                 recomb_link.ac_logprob,
                                 recomb_link.lm_logprob + lm_logprob_diff,
                                 recomb_link.transitions)
            from_node.out_links.append(new_link)
            // Tokens never contain null words, so we can be sure that
            // word_to_link maps in our new lattice never skip nodes.
            assert word is not None
            from_node.word_to_link[word] = new_link
            self.links.append(new_link)

        if oov_words:
            logging.debug("Out-of-vocabulary words in lattice: %s",
                          ", ".join(oov_words))

        final_node.id = len(self.nodes)
        self.nodes.append(final_node)

    def _add_word_maps(self, nodes):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: senarvi/theanolm
Commit Name: 7380900edb073add959fc9cf4b67f93f0dc7a5c8
Time: 2017-11-08
Author: seppo.git@marjaniemi.com
File Name: theanolm/scoring/rescoredlattice.py
Class Name: RescoredLattice
Method Name: __init__


Project Name: Microsoft/nni
Commit Name: 7ee5036b2858c2b18bf113d56059ae6d30656113
Time: 2020-06-10
Author: 49771382+zheng-ningxin@users.noreply.github.com
File Name: src/sdk/pynni/nni/_graph_utils.py
Class Name: TorchModuleGraph
Method Name: _build_graph


Project Name: pantsbuild/pants
Commit Name: 91d4af0d59877cdc19b76854f3c90ed0341a367e
Time: 2019-12-10
Author: john.sirois@gmail.com
File Name: src/python/pants/backend/python/subsystems/pex_build_util.py
Class Name: PexBuilderWrapper
Method Name: add_resolved_requirements