original_docstring: Check whether a string (typically line in data file) is a well-formed double-colon expression
docstring: Check whether a string (typically line in data file) is a well-formed double-colon expression
docstring_tokens: Check whether a string ( typically line in data file ) is a well - formed double - colon expression
code: def double_colon_del_list_validation(s: str, line_id: str, filename: str,
                                       valid_slots: List[str], required_slot_dict: Dict[str, List[str]]) -> bool:
      """Check whether a string (typically line in data file) is a well-formed double-colon expression"""
      valid = True
      prev_slots = []
      if slots := re.findall(r'::([a-z]\S*)', s, re.IGNORECASE):
          head_slot = slots[0]
          if (required_slots := required_slot_dict.get(head_slot, None)) is None:
              valid = False
              log.warning(f'found invalid head-slot ::{head_slot} in line {line_id} in {filename}')
              required_slots = []
      else:
          log.warning(f'found no slots in line {line_id} in {filename}')
          return False
      # Check for duplicates and unexpected slots
      for slot in slots:
          if slot in valid_slots:
              if slot in prev_slots:
                  valid = False
                  log.warning(f'found duplicate slot ::{slot} in line {line_id} in {filename}')
              else:
                  prev_slots.append(slot)
          else:
              valid = False
              log.warning(f'found unexpected slot ::{slot} in line {line_id} in {filename}')
      # Check for missing required slots
      if required_slots:
          for slot in required_slots:
              if slot not in prev_slots:
                  valid = False
                  log.warning(f'missing required slot ::{slot} in line {line_id} in {filename}')
      # Check for ::slot syntax problems
      if m := re.match(r'.*?(\S+::[a-z]\S*)', s):
          valid = False
          value = m.group(1)
          if re.match(r'.*:::', value):
              log.warning(f"suspected spurious colon in '{value}' in line {line_id} in {filename}")
          else:
              log.warning(f"# Warning: suspected missing space in '{value}' in line {line_id} in {filename}")
      # Element starts with single colon (:). Might be slot with a missing colon.
      if m := re.match(r'(?:.*\s)?(:[a-z]\S*)', s):
          # Exception :emoji-shortcut:
          if re.match(r':[a-z][-_a-z]*[a-z]:$', m.group(1), flags=re.IGNORECASE) \
                  and re.match(r'.*\b(?:symbol|emoji)\b', s, flags=re.IGNORECASE):
              pass
          elif re.match(r'.*::syntax-checked True\b', s):
              pass
          else:
              valid = False
              log.warning(f"suspected missing colon in '{m.group(1)}' in line {line_id} in {filename}")
      return valid
code_tokens: def double_colon_del_list_validation ( s : str , line_id : str , filename : str , valid_slots : List [ str ] , required_slot_dict : Dict [ str , List [ str ] ] ) -> bool : valid = True prev_slots = [ ] if slots := re . findall ( r'::([a-z]\S*)' , s , re . IGNORECASE ) : head_slot = slots [ 0 ] if ( required_slots := required_slot_dict . get ( head_slot , None ) ) is None : valid = False log . warning ( f'found invalid head-slot ::{head_slot} in line {line_id} in {filename}' ) required_slots = [ ] else : log . warning ( f'found no slots in line {line_id} in {filename}' ) return False for slot in slots : if slot in valid_slots : if slot in prev_slots : valid = False log . warning ( f'found duplicate slot ::{slot} in line {line_id} in {filename}' ) else : prev_slots . append ( slot ) else : valid = False log . warning ( f'found unexpected slot ::{slot} in line {line_id} in {filename}' ) if required_slots : for slot in required_slots : if slot not in prev_slots : valid = False log . warning ( f'missing required slot ::{slot} in line {line_id} in {filename}' ) if m := re . match ( r'.*?(\S+::[a-z]\S*)' , s ) : valid = False value = m . group ( 1 ) if re . match ( r'.*:::' , value ) : log . warning ( f"suspected spurious colon in '{value}' in line {line_id} in {filename}" ) else : log . warning ( f"# Warning: suspected missing space in '{value}' in line {line_id} in {filename}" ) if m := re . match ( r'(?:.*\s)?(:[a-z]\S*)' , s ) : if re . match ( r':[a-z][-_a-z]*[a-z]:$' , m . group ( 1 ) , flags = re . IGNORECASE ) and re . match ( r'.*\b(?:symbol|emoji)\b' , s , flags = re . IGNORECASE ) : pass elif re . match ( r'.*::syntax-checked True\b' , s ) : pass else : valid = False log . warning ( f"suspected missing colon in '{m.group(1)}' in line {line_id} in {filename}" ) return valid
short_docstring: Check whether a string (typically line in data file) is a well-formed double-colon expression
short_docstring_tokens: Check whether a string ( typically line in data file ) is a well - formed double - colon expression
comment: """Check whether a string (typically line in data file) is a well-formed double-colon expression"""$SEP$# Check for duplicates and unexpected slots$SEP$# Check for missing required slots$SEP$# Check for ::slot syntax problems$SEP$# Element starts with single colon (:). Might be slot with a missing colon.$SEP$# Exception :emoji-shortcut: