petite-difference-challenge2/main.py

30 lines
550 B
Python
Raw Normal View History

2022-04-27 10:58:09 +02:00
import random
man = ['em', '']
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)