def write_semeval_predictions(experiment, final=False): config = get_config() twitter_test = config.get('semeval', 'twitter_test') twitter_predict = config.get('semeval', 'twitter_predict') sms_test = config.get('semeval', 'sms_test') sms_predict = config.get('semeval', 'sms_predict') # task2-B-twitter with open(twitter_test) as f, \ open(twitter_predict + ('.final' if final else ''), mode='w') as w: for instance in task_b_generator(f): sid, uid, label, text = instance features = experiment.extractor.extract(instance.text) label, probability = experiment._predict(features) w.write('\t'.join([sid, uid, label, text]) + '\n') # task2-B-SMS with open(sms_test) as f, \ open(sms_predict + ('.final' if final else ''), mode='w') as w: for instance in task_b_generator(f): sid, uid, label, text = instance features = experiment.extractor.extract(instance.text) label, probability = experiment._predict(features) w.write('\t'.join([sid, uid, label, text]) + '\n')
def setup(self): self.tweets = s.task_b_generator(EXAMPLE_DATA)