class_docstr: Chinese Text Processor class
class_docstr_tok: ["Chinese","Text","Processor","class"]
docstr: NER function.
  :param str sentence: the sentence need to be ner
  :return two forms of tags
      The first is the triple form (tags,start,end)
      The second is the list form, which marks the ner label of each word
      such as 周小明去玩
      ['Nh', 'Nh', 'Nh', 'O', 'O']
docstr_tok: ["NER","function",".",":","param","str","sentence",":","the","sentence","need","to","be","ner",":","return","two","forms","of","tags","The","first","is","the","triple","form","(","tags",",","start",",","end",")","The","second","is","the","list","form",",","which","marks","the","ner","label","of","each","word","such","as","\u5468\u5c0f\u660e\u53bb\u73a9","[","'Nh","'",",","'Nh","'",",","'Nh","'",",","'","O","'",",","'","O","'","]"]
code: def get_ner(self, sentence):
      r"""
      NER function.
      :param str sentence: the sentence need to be ner
      :return two forms of tags
          The first is the triple form (tags,start,end)
          The second is the list form, which marks the ner label of each word
          such as 周小明去玩
          ['Nh', 'Nh', 'Nh', 'O', 'O']
      """
      assert isinstance(sentence, (list, str))
      from ltp import LTP
  
      if isinstance(sentence, list):
          # Turn the list into sentence
          tmp = ""
          for word in sentence:
              tmp += word
          sentence = tmp
  
      if not sentence:
          return [], []
  
      if self.__ner is None:
          self.__ner = LTP()
      seg, hidden = self.__ner.seg([sentence])
      seg = seg[0]
      ner = self.__ner.ner(hidden)
      ner = ner[0]
  
      ner_label = len(sentence) * ["O"]
      for i in range(len(ner)):
          tag, start, end = ner[i]
          tmp = 0
          for j in range(start):
              tmp += len(seg[j])
          start = tmp
          tmp = 0
          for j in range(end + 1):
              tmp += len(seg[j])
          end = tmp
          ner[i] = (tag, start, end - 1)
          for j in range(start, end):
              ner_label[j] = tag
  
      return ner, ner_label
  
file_path: textflint/textflint/common/preprocess/cn_processor.py
imports: import threading
  from ..settings import CN_SYNONYM_PATH, CN_ANTONYM_PATH
  from ..utils.install import download_if_needed
label_desc: Use image node_id 4 for calling the CnProcessor obj's underlying member method code with example usage: obj.get_ner(sentence) and returns: ner,  ner_label, list,  list