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
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:
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 7
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: allenai/allennlp
Commit Name: adeb1b1278619ff2d74d4fd82825e50a36f95ff4
Time: 2020-03-27
Author: dirkg@allenai.org
File Name: allennlp/data/token_indexers/pretrained_transformer_indexer.py
Class Name: PretrainedTransformerIndexer
Method Name: _add_encoding_to_vocabulary_if_needed
Project Name: chainer/chainercv
Commit Name: 19c8ee690ccf74947b379862a5290c9b53f96de7
Time: 2017-03-15
Author: yuyuniitani@gmail.com
File Name: chainercv/transforms/image/chw_to_pil_image.py
Class Name:
Method Name: chw_to_pil_image