class_docstr: WSDSample Class
class_docstr_tok: ["WSDSample","Class"]
docstr: Get pos tag for list of words.
  :param words: a list of words to be tagged,e.g.['he',['pointed','out']]
  :param wn: default false;true if get wordnet-level pos tag
  :return: tagged_sent: pos tag for list of words
docstr_tok: ["Get","pos","tag","for","list","of","words",".",":","param","words",":","a","list","of","words","to","be","tagged",",","e.g",".","[","'he","'",",","[","'pointed","'",",","'out","'","]","]",":","param","wn",":","default","false",";","true","if","get","wordnet-level","pos","tag",":","return",":","tagged_sent",":","pos","tag","for","list","of","words"]
code: def tag_words(self, words, wn=False):
      r"""
      Get pos tag for list of words.
      :param words: a list of words to be tagged,e.g.['he',['pointed','out']]
      :param wn: default false;true if get wordnet-level pos tag
      :return: tagged_sent: pos tag for list of words
      """
  
      def normalize_pos(pos):
          r"""
          Convert pos tag into wordnet-level pos tag
          :param pos: original pos tag
          :return: pp: wordnet-level pos tag
          """
          if pos in ["a", "r", "n", "v", "s"]:
              pp = pos
          else:
              norm_dict = {"JJ": "a", "VB": "v", "NN": "n", "RB": "r"}
              key = pos[:2]
              if key in norm_dict.keys():
                  pp = norm_dict[key]
              else:
                  pp = None
          return pp
  
      def convert_pos(pos):
          r"""
          Convert pos tag into pos tag applied in xml file.
          :param pos:original pos tag
          :return:pp: pos tag applied in xml file
          """
          if pos in PUNC:
              pp = "."
          else:
              convert_dict = {
                  "JJ": "ADJ",
                  "VB": "VERB",
                  "NN": "NOUN",
                  "RB": "ADV",
                  "CD": "NUM",
                  "DT": "DET",
                  "IN": "ADP",
                  "CC": "CONJ",
                  "POS": "PRT",
                  "PRP": "PRON",
              }
              key2 = pos[:2]
              key3 = pos[:3]
              if key2 in convert_dict.keys():
                  pp = convert_dict[key2]
              elif key3 in convert_dict.keys():
                  pp = convert_dict[key3]
              else:
                  pp = "X"
          return pp
  
      tagged_sent = []
      for item in words:
          assert isinstance(item, str) or isinstance(
              item, list
          ), "invalid format of list"
          if isinstance(item, str):
              if wn is True:
                  tagged_sent.append(
                      normalize_pos(nltk.pos_tag([item])[0][1])
                  )
              else:
                  if item in PUNC:
                      tagged_sent.append(".")
                  else:
                      tagged_sent.append(
                          convert_pos(nltk.pos_tag([item])[0][1])
                      )
          elif isinstance(item, list):
              for word in item:
                  assert isinstance(word, str), "invalid format of word"
              pos_list = [t[1] for t in nltk.pos_tag(item)]
              for i in range(len(pos_list)):
                  if item[i] in PUNC:
                      pos_list[i] = "."
              if wn is True:
                  tagged_sent.append(
                      [normalize_pos(t) for t in pos_list]
                  )
              else:
                  tagged_sent.append([convert_pos(t) for t in pos_list])
  
      return tagged_sent
  
imports: from .sample import Sample
  from ..field import TextField, ListField
  import json
  from ....common.settings import TASK_MASK, PUNC
  import nltk
label_desc: Use image node_id 9 for calling the WSDSample obj's underlying member method code with example usage: obj.tag_words(words, wn) and returns: tagged_sent, pp, pp