class_docstr: Use Bert to generate words.
  
  Example::
  
      小明喜欢看书 -> 小明喜欢看报纸
docstr: Generate word function.
  
  :param str sentence: chinese sentence
  :param list label: Chinese word segmentation tag
  :param list pos_tags: sentence's pos tag
  :return list: two list include the pos and labels which are changed
docstr_tok: ["Generate","word","function",".",":","param","str","sentence",":","chinese","sentence",":","param","list","label",":","Chinese","word","segmentation","tag",":","param","list","pos_tags",":","sentence","'s","pos","tag",":","return","list",":","two","list","include","the","pos","and","labels","which","are","changed"]
code: def _get_transformations(self, sentence, label, pos_tags, mask):
      r"""
      Generate word function.
  
      :param str sentence: chinese sentence
      :param list label: Chinese word segmentation tag
      :param list pos_tags: sentence's pos tag
      :return list: two list include the pos and labels which are changed
  
      """
      assert len(sentence) == len(label)
      cnt = 0
      for i in range(len(pos_tags)):
          tag, start, end = pos_tags[i]
          start += cnt
          end += cnt
          # find the pos that can generate word
          # Situation 1: v + single n
          # we generate double n replace single n
          if (
              label[start] == "B"
              and label[start + 1] == "E"
              and i < len(pos_tags) - 1
              and pos_tags[i][0] == "v"
              and end == start + 1
              and self.check_part_pos(sentence[start + 1])
          ):
              token = ""
              for j in range(len(sentence)):
                  if j != start + 1:
                      token += sentence[j] + " "
                  else:
                      token += "[MASK] [MASK] "
              change = self.create_word(token)
              if change != "":
                  if self.check(start, end, mask):
                      sentence = (
                          sentence[: start + 1]
                          + change
                          + sentence[start + 2 :]
                      )
                      label = (
                          label[:start]
                          + ["S", "B", "E"]
                          + label[start + 2 :]
                      )
                      mask = (
                          mask[: start + 1]
                          + [MODIFIED_MASK] * 2
                          + mask[start + 2 :]
                      )
                      cnt += 1
                      start += 1
          # Situation 1: n + n + n
          # we generate double n replace single n and split one word into two
          elif (
              label[start : start + 3] == ["B", "M", "E"]
              and tag == "n"
              and end - start == 2
          ):
              token = ""
              start += 2
              for i in range(len(sentence)):
                  if i != start:
                      token += sentence[i] + " "
                  else:
                      token += "[MASK] [MASK] "
              change = self.create_word(token)
              if self.check(start, end, mask):
                  if change != "":
                      sentence = (
                          sentence[:start]
                          + change
                          + sentence[start + 1 :]
                      )
                      label = (
                          label[: start - 1]
                          + ["E", "B", "E"]
                          + label[start + 1 :]
                      )
                      mask = (
                          mask[:start]
                          + [MODIFIED_MASK] * 2
                          + mask[start + 1 :]
                      )
                      cnt += 1
                      start += 1
          start += 1
  
      return sentence, label, mask
  
file_path: textflint/textflint/generation/transformation/CWS/cn_mlm.py
imports: import torch
  from transformers import BertTokenizer, BertForMaskedLM
  from ..transformation import Transformation
  from ....input.component.field.cn_text_field import CnTextField
  from ....common.preprocess.cn_processor import CnProcessor
  from ....common.settings import ORIGIN, MODIFIED_MASK
label_desc: Use image node_id 5 for calling the CnMLM obj's underlying member method code with example usage: obj._get_transformations(sentence, label, pos_tags, mask) and returns: sentence,  label,  mask