Commit 581ff39b by Paktalin

finished the interface

parent c1ae90b8
......@@ -85,7 +85,9 @@ def construct_df_of_verbs(initial_df):
print(verbs_df)
if __name__ == '__main__':
df = read_csv('cleaned_dataframe.csv', sep='~')
df.columns = ['distance', 'noun_like', 'noun_like_form', 'noun_like_pos', 'sentence', 'verb', 'verbs_form']
construct_df_of_verbs(df)
\ No newline at end of file
# df = read_csv('cleaned_dataframe.csv', sep='~')
# df.columns = ['distance', 'noun_like', 'noun_like_form', 'noun_like_pos', 'sentence', 'verb', 'verbs_form']
# construct_df_of_verbs(df)
df = read_csv('verbs.csv', sep='~', header=0)
print(len(df.columns))
\ No newline at end of file
......@@ -33,13 +33,21 @@ def plot_results(X, R, forms, df):
print('Cluster', k)
print(df[R[:,k] == 1]['verb'])
def print_verb_info(verb, df, X, R, forms):
current_verb_index = df[df['verb'] == verb].index
print_cluster(current_verb_index, df, X, R)
pie_chart_verb(X[current_verb_index][0].tolist(), forms.tolist(), verb)
print_sample_usages(verb)
def print_verb_info(df, X, R, forms):
while(True):
verb = input('\nPlease, enter the verb. Or \'e\' to exit: ')
if verb == 'e':
break
elif len(df[df['verb'] == verb]) != 0:
current_verb_index = df[df['verb'] == verb].index
print_cluster(current_verb_index, df, X, R)
pie_chart_verb(X[current_verb_index][0].tolist(), forms.tolist(), verb)
print_sample_usages(verb)
else:
print('Sorry. The verb was not found')
def print_cluster(current_verb_index, df, X, R):
print('\nSimilar verbs are:')
R_verb = R[current_verb_index][0]
k = np.where(R_verb == 1)[0][0]
similar_verbs = df[R[:,k] == 1]['verb']
......@@ -50,6 +58,7 @@ def print_cluster(current_verb_index, df, X, R):
print(list(similar_verbs_dict.keys())[1:])
def print_sample_usages(verb):
print('\nSample usages of the verb:')
df = read_csv('cleaned_dataframe.csv', sep='~')
df.columns = ['distance', 'noun_like', 'noun_like_form', 'noun_like_pos', 'sentence', 'verb', 'verbs_form']
sentences = df[df['verb'] == verb]['sentence'].tolist()
......@@ -69,4 +78,4 @@ def print_sample_usages(verb):
R = np.genfromtxt('R.csv', delimiter='~')
M = np.genfromtxt('M.csv', delimiter='~')
X, verbs, forms, df = get_verbs_data()
print_verb_info('armastama', df, X, R, forms)
\ No newline at end of file
print_verb_info(df, X, R, forms)
\ No newline at end of file
......@@ -26,6 +26,8 @@ def plot_form_pdf(X, forms):
ax = pd.DataFrame(x).plot.density(bw_method=0.1)
labels.append('%s - mean: %.4f std: %.4f' % (forms[i], x.mean(), np.std(x)))
plt.xlim(-0.01, 0.015)
plt.xlabel('Usages per sample')
plt.yticks([])
plt.legend(labels=labels)
plt.show()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment