import random man = ['em', 'ił'] woman = ['am', 'ła'] predictions = [] directory = 'dev-1' with open(f'{directory}/in.tsv') as f: data = f.readlines() for text in data: words = text.split() result = 0 for word in words: if word[-2:] in man: result += 1 elif word[-2:] in woman: result -= 1 if result == 0: result = random.random() - 0.5 predictions.append('0\n' if result < 0 else '1\n') with open(f'{directory}/out.tsv', 'w') as f: f.writelines(predictions)