MCPcopy
hub / github.com/OpenNMT/OpenNMT-py / apply

Method apply

onmt/transforms/bart.py:306–318  ·  view source on GitHub ↗
(self, tokens)

Source from the content-addressed store, hash-verified

304 return tokens[offset:] + tokens[0:offset]
305
306 def apply(self, tokens):
307 if self.permute_sent_ratio > 0.0:
308 tokens = self.permute_sentences(tokens, self.permute_sent_ratio)
309
310 if self.mask_ratio > 0.0:
311 tokens = self.whole_word_mask(tokens, self.mask_ratio)
312
313 if self.insert_ratio > 0.0:
314 tokens = self.insertion_noise(tokens, self.insert_ratio)
315
316 if self.rotate_ratio > 0.0:
317 tokens = self.rolling_noise(tokens, self.rotate_ratio)
318 return tokens
319
320 def __repr__(self):
321 cls_name = type(self).__name__

Callers 15

test_sentence_permuteMethod · 0.95
test_rotateMethod · 0.95
test_token_insertMethod · 0.95
test_token_maskMethod · 0.95
test_whole_word_maskMethod · 0.95
test_span_infillingMethod · 0.95
applyMethod · 0.45
maybe_transform_featsMethod · 0.45
test_transform_pipeMethod · 0.45
test_prefixMethod · 0.45
test_filter_too_longMethod · 0.45
test_bpeMethod · 0.45

Calls 4

permute_sentencesMethod · 0.95
whole_word_maskMethod · 0.95
insertion_noiseMethod · 0.95
rolling_noiseMethod · 0.95

Tested by 15

test_sentence_permuteMethod · 0.76
test_rotateMethod · 0.76
test_token_insertMethod · 0.76
test_token_maskMethod · 0.76
test_whole_word_maskMethod · 0.76
test_span_infillingMethod · 0.76
test_transform_pipeMethod · 0.36
test_prefixMethod · 0.36
test_filter_too_longMethod · 0.36
test_bpeMethod · 0.36
test_sentencepieceMethod · 0.36
test_pyonmttok_bpeMethod · 0.36