textattack.transformations.word_swaps.chn_transformations package

chinese_transformations package

Submodules

Word Swap by chinese homophone

class textattack.transformations.word_swaps.chn_transformations.chinese_homophone_character_swap.ChineseHomophoneCharacterSwap[source]

Bases: WordSwap

Transforms an input by replacing its words with synonyms provided by a homophone dictionary.

Word Swap by chinese morphonym

class textattack.transformations.word_swaps.chn_transformations.chinese_morphonym_character_swap.ChineseMorphonymCharacterSwap(**kwargs)[source]

Bases: WordSwap

Transforms an input by replacing its words with synonyms provided by a morphonym dictionary.

Word Swap by chinese hownet

class textattack.transformations.word_swaps.chn_transformations.chinese_word_swap_hownet.ChineseWordSwapHowNet(topk=5)[source]

Bases: WordSwap

Transforms an input by replacing its words with synonyms provided by OpenHownet http://nlp.csai.tsinghua.edu.cn/.

Word Swap by chinese BERT-Masked LM.

class textattack.transformations.word_swaps.chn_transformations.chinese_word_swap_masked.ChineseWordSwapMaskedLM(task='fill-mask', model='xlm-roberta-base', **kwargs)[source]

Bases: WordSwap

Generate potential replacements for a word using a masked language model.

get_replacement_words(current_text, indice_to_modify)[source]
textattack.transformations.word_swaps.chn_transformations.chinese_word_swap_masked.is_cjk(char)[source]