0066f83bc6f9f3861119db2593c3007796d2056c,deeppavlov/models/seq2seq_go_bot/kb.py,KnowledgeBaseEntityNormalizer,normalize,#KnowledgeBaseEntityNormalizer#Any#Any#,151

Before Change


        utter = " ".join(tokens)
        for entity, value in self.kb([key])[0]:
            // is value is tokens, get string
            if isinstance(value, (list, tuple)):
                value = " ".join(value)
            if value:
                utter = utter.replace(value, entity)
            else:
                log.debug("Empty value for knowledge base entry with key = {}"

After Change


    def normalize(self, tokens, entries):
        for entity, ent_tokens in sorted(entries, key=lambda e: -len(e[1])):
            ent_num_tokens = len(ent_tokens)
            if " ".join(ent_tokens).strip():
                for i in range(len(tokens)):
                    if tokens[i:i+ent_num_tokens] == ent_tokens:
                        if self.remove:
                            tokens = tokens[:i] + tokens[i+ent_num_tokens:]
                        else:
                            tokens = tokens[:i] + [entity] + tokens[i+ent_num_tokens:]
        return tokens

    def denormalize(self, tokens, entries):
        for entity, ent_tokens in entries:
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 8

Instances


Project Name: deepmipt/DeepPavlov
Commit Name: 0066f83bc6f9f3861119db2593c3007796d2056c
Time: 2018-08-30
Author: mary.vikhreva@gmail.com
File Name: deeppavlov/models/seq2seq_go_bot/kb.py
Class Name: KnowledgeBaseEntityNormalizer
Method Name: normalize


Project Name: bethgelab/foolbox
Commit Name: 9c24154b9b465e35dbeb81780279f37fd685ffd9
Time: 2019-10-17
Author: rzrolandzimmermann@gmail.com
File Name: foolbox/batching.py
Class Name:
Method Name: run_sequential


Project Name: bethgelab/foolbox
Commit Name: 9c24154b9b465e35dbeb81780279f37fd685ffd9
Time: 2019-10-17
Author: rzrolandzimmermann@gmail.com
File Name: foolbox/batching.py
Class Name:
Method Name: run_parallel