code: def build_detection_class(folder, dataset_filename,
                            label, sender_known=True):
      
      with open(dataset_filename, 'a') as dataset:
          for filename in os.listdir(folder):
              filename = os.path.join(folder, filename)
              sender, msg = parse_msg_sender(filename, sender_known)
              if sender is None or msg is None:
                  continue
              msg = re.sub('|'.join(ANNOTATIONS), '', msg)
              X = build_pattern(msg, features(sender))
              X.append(label)
              labeled_pattern = ','.join([str(e) for e in X])
              dataset.write(labeled_pattern + '\n')
docs: Builds signature detection class.
  
      Signature detection dataset includes patterns for two classes:
      * class for positive patterns (goes with label 1)
      * class for negative patterns (goes with label -1)
  
      The patterns are build of emails from `folder` and appended to
      dataset file.
  
      >>> build_signature_detection_class('emails/P', 'train.data', 1)