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

Before Change


            // 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 = {}"
                          .format(key))
        return utter.split()

    def denormalize(self, key, tokens):
        for entity, value in self.kb([key])[0]:

After Change


        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: 5

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: ray-project/ray
Commit Name: 732197e23a937b7b6d196936519c16ec6317ea9f
Time: 2021-03-08
Author: sven@anyscale.io
File Name: rllib/execution/train_ops.py
Class Name: TrainTFMultiGPU
Method Name: __call__


Project Name: ray-project/ray
Commit Name: 3d8c1cbae6a4172ad3fd66b387b846634513f7f2
Time: 2020-12-11
Author: simon.mo@hey.com
File Name: release/long_running_tests/workloads/serve.py
Class Name:
Method Name: echo