class_docstr: ABSASample Class
class_docstr_tok: ["ABSASample","Class"]
docstr: Check whether aspect words and opinion words are
      in the correct position.
  
  :return bool: whether format of data is legal.
docstr_tok: ["Check","whether","aspect","words","and","opinion","words","are","in","the","correct","position",".",":","return","bool",":","whether","format","of","data","is","legal","."]
code: def is_legal(self):
      r"""
      Check whether aspect words and opinion words are
          in the correct position.
  
      :return bool: whether format of data is legal.
  
      """
  
      terms = self.terms
      copy_sent = self.sentence.words
  
      for term_id in terms:
          opinions_spans = terms[term_id]["opinion_position"]
  
          for i in range(len(opinions_spans)):
              position = opinions_spans[i]
              opinion_from = position[0]
              opinion_to = position[1]
              opinion = copy_sent[opinion_from:opinion_to]
              if opinion_from == opinion_to or opinion == "":
                  return False
  
          term_from = terms[term_id]["from"]
          term_to = terms[term_id]["to"]
          aspect = copy_sent[term_from:term_to]
          if term_from == term_to or aspect == "":
              return False
  
      return True
  
imports: from .sample import Sample
  from ..field import TextField
  from ....common.utils.error import FlintError
label_desc: Use image node_id 6 for calling the ABSASample obj's underlying member method code with example usage: obj.is_legal() and returns: True, False, False