petite-difference-challenge2/run.py
2022-04-20 21:15:53 +02:00

64 lines
1.6 KiB
Python

import random
def predict(text):
score = 0
for word in m_vocabulary:
if word in text:
score += 1
for word in f_vocabulary:
if word in text:
score -= 1
if score == 0:
return random.randint(0, 1)
if score >0:
return 1
if score <0:
return 0
m_vocabulary = ['windows', 'pc', 'lagi', 'komputer', 'komputerze', 'aucie', 'auto', 'samochód', 'samochodzie', 'piwie', 'piwo', 'alkoholu', 'alkohol', 'żonie', 'żona', 'xboxie', 'xbox', 'mecz', 'meczu', 'XD', 'stary', 'staremu']
f_vocabulary = ['ciasto', 'porodzie', 'ciąży', 'ciąża', 'tabletki', 'zakupy', 'zakupach', 'mężem', 'mąż', 'nasze', 'my', 'dzieckiem', 'dziecko', 'domu', 'dom', 'mieszkaniu', 'mieszkanie', 'kocham', 'kocha', 'chłopakowai', 'chłopak', 'haha', 'boże', 'uh', 'uhh', ":)", 'mama', 'mamie', 'włosy']
with open('dev-0/in.tsv', 'r', encoding='utf8') as f:
dev0_x = f.readlines()
with open('dev-0/expected.tsv', 'r', encoding='utf8') as f:
dev0_y = f.readlines()
dev0 = zip(dev0_x, dev0_y)
with open('dev-0/out.tsv', 'wt') as f:
for x, y in list(dev0):
f.write(str(predict(x))+'\n')
with open('dev-1/in.tsv', 'r', encoding='utf8') as f:
dev1_x = f.readlines()
with open('dev-1/expected.tsv', 'r', encoding='utf8') as f:
dev1_y = f.readlines()
dev1 = zip(dev1_x, dev1_y)
with open('dev-1/out.tsv', 'wt') as f:
for x, y in list(dev1):
f.write(str(predict(x))+'\n')
with open('test-A/in.tsv', 'r', encoding='utf8') as f:
testA_x = f.readlines()
with open('test-A/out.tsv', 'wt') as f:
for x in list(testA_x):
f.write(str(predict(x))+'\n')