MCPcopy
hub / github.com/QData/TextAttack / test_chinese_morphonym_character_swap

Function test_chinese_morphonym_character_swap

tests/test_transformations.py:118–132  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

116
117
118def test_chinese_morphonym_character_swap():
119 from textattack.augmentation import Augmenter
120 from textattack.transformations.word_swaps.chn_transformations import (
121 ChineseMorphonymCharacterSwap,
122 )
123
124 augmenter = Augmenter(
125 transformation=ChineseMorphonymCharacterSwap(),
126 pct_words_to_swap=0.1,
127 transformations_per_example=5,
128 )
129 s = "自然语言处理。"
130 augmented_text_list = augmenter.augment(s)
131 augmented_s = "自然语言处埋。"
132 assert augmented_s or s in augmented_text_list
133
134
135def test_chinese_word_swap_hownet():

Callers

nothing calls this directly

Calls 3

augmentMethod · 0.95
AugmenterClass · 0.90

Tested by

no test coverage detected