#!/usr/bin/python3

import sys
import pickle
from math import log, exp
from tokenizer import tokenize

#Load model
model = pickle.load(open("model.pkl","rb"))
weights, word_to_index_mapping, word_count = model
sum = 0
counter = 0

for line in sys.stdin:
    document = line.rstrip()
    fields = document.split('\t')
    document = fields[0]
    terms = tokenize(document)

    y_predicted = weights[0]
    for word in terms:
        y_predicted += weights[word_to_index_mapping.get(word,0)] * log(word_count.get(word,0) / len(word_count) + 1)
    sum += y_predicted
    counter += 1
    if y_predicted <= 0:
        print(0)
    else:
        print(1)

#print(sum / counter)