class_docstr: WSCSample Class
class_docstr_tok: ["WSCSample","Class"]
docstr: Check whether 'text', 'target' and 'label' is legal
  
  :param dict data: contains 'text', 'target' and 'label' keys.
  :return:
  
  example:
  {
      "text":"The city councilmen refused the demonstrators a permit because they feared violence.",
      "target":{"span1_index":4, "span2_index":9,
              "span1_text":"the demonstrators","span2_text":"they"},
      "label":false
      "index":2
  }
docstr_tok: ["Check","whether","'text","'",",","'target","'","and","'label","'","is","legal",":","param","dict","data",":","contains","'text","'",",","'target","'","and","'label","'","keys",".",":","return",":","example",":","{","``","text","''",":","''","The","city","councilmen","refused","the","demonstrators","a","permit","because","they","feared","violence",".","``",",","``","target","''",":","{","``","span1_index","''",":4",",","``","span2_index","''",":9",",","``","span1_text","''",":","''","the","demonstrators","''",",","''","span2_text","''",":","''","they","''","}",",","``","label","''",":","false","``","index","''",":2","}"]
code: def check_data(self, data):
      r"""
      Check whether 'text', 'target' and 'label' is legal
  
      :param dict data: contains 'text', 'target' and 'label' keys.
      :return:
  
      example:
      {
          "text":"The city councilmen refused the demonstrators a permit because they feared violence.",
          "target":{"span1_index":4, "span2_index":9,
                  "span1_text":"the demonstrators","span2_text":"they"},
          "label":false
          "index":2
      }
      """
      # print("data", data['text'])
  
      assert "text" in data and isinstance(data["text"], str), (
          "text should be in data, and "
          "the type of context should be str"
      )
      assert "index" in data and isinstance(data["index"], int), (
          "index should be in data, and "
          "the type of context should be int"
      )
      assert "target" in data and isinstance(
          data["target"], dict
      ), "target should be in data, and the type of context should be dict"
      assert "label" in data and isinstance(
          data["label"], int
      ), "label should be in data, and the type of context should be int"
      target = data["target"]
      assert "noun1_idx" in target and isinstance(
          target["noun1_idx"], int
      ), (
          "noun1_idx should be in target, "
          "type of noun1_idx should be int "
      )
      assert "noun2_idx" in target and isinstance(
          target["noun2_idx"], int
      ), (
          "noun2_idx should be in target, "
          "type of noun2_idx should be int "
      )
      assert "pron_idx" in target and isinstance(
          target["pron_idx"], int
      ), (
          "pron_idx should be in target, "
          "type of pron_idx should be int "
      )
      assert "noun1" in target and isinstance(target["noun1"], str), (
          "noun1 should be in target, " "type of noun1 should be str "
      )
      assert "noun2" in target and isinstance(target["noun1"], str), (
          "noun2 should be in target, " "type of noun2 should be str "
      )
      assert "pron" in target and isinstance(target["pron"], str), (
          "pron should be in target, " "type of pron should be str "
      )
  
imports: from copy import deepcopy
  import nltk
  import string
  from .sample import Sample
  from ..field import TextField
  from ....common.utils.error import FlintError
  from ....common.utils.list_op import normalize_scope
label_desc: Use image node_id 3 for calling the WSCSample obj's underlying member method code with example usage: obj.check_data(data) without return types