# Ling 115 kwiseth
# Prompt user for two different word counts and then calculate the
# expected probability and the observed probability of the second word
# following the first. If observed probability is larger than expected,
# the 2-gram is likely a multi-word expression, so identify it as a
# hit; otherwise, it's a miss.
#
# hw3.q3.py
# An orienting welcome message before prompting the user for numbers
print(' ')
print('Ling 115 Observed vs. Expected Probability Calculator')
print(' ')
print('---------------------------------------------------------------')
print(' ')
print('This program calculates expected probability and observed probability')
print('of word combinations given a particular corpus size and compares ')
print('the two probabilities to determine whether the bi-gram (the pair ')
print('of words) is likely to be a multi-word expression (\'White House\',')
print('for example, which results in a \'hit\'), or not (\'green house\',')
print('which results in a \'miss\'.')
print(' ')
print('---------------------------------------------------------------')
# Create the variables for our input data
corp_wd_t = int(raw_input('Enter the total number of words in the corpus: '))
wd_1_t = int(raw_input('Enter the number of instances (tokens) of the first word: '))
wd_2_t = int(raw_input('Enter the number of times the second word appears in the corpus: '))
wd_1_wd_2_t = int(raw_input('Enter the number of times the second word follows the first: '))
# testing some values
# print(corp_wd_t)
# print(wd_1_t)
# print(wd_2_t)
# print(wd_1_wd_2_t)
exp_prob = float(wd_1_t)/float(corp_wd_t) * float(wd_2_t)/float(corp_wd_t)
obs_prob = float(wd_1_wd_2_t)/float(corp_wd_t)
# testing the probability calculations
# comp_exp_prob = 1-exp_prob
# comp_obs_prob = 1-obs_prob
# print(exp_prob, " ", comp_exp_prob)
# print(obs_prob, " ", comp_obs_prob)
if obs_prob <= exp_prob:
print("miss")
else:
print("hit")