Mark7549 commited on
Commit
d2c01c1
·
1 Parent(s): 4e0c8c4

fixed bug where n was always 10 in nearest neighbours function

Browse files
Files changed (2) hide show
  1. app.py +5 -3
  2. word2vec.py +1 -1
app.py CHANGED
@@ -16,13 +16,15 @@ with gr.Blocks() as demo:
16
  inputs=[
17
  gr.Textbox(label='Word 1 (required)', placeholder='χρηστήριον'),
18
  gr.Radio(label='Time slice (required)', choices=["archaic_cbow", "classical_cbow", "early_roman_cbow", "hellen_cbow", "late_roman_cbow"]),
19
- gr.Slider(label='Number of neighbours', minimum=1, maximum=50, step=1, value=10)
20
  ],
21
  outputs=gr.DataFrame(
22
  label="Result",
23
- headers=["Word", "Time slice", "Cosine similarity"]
 
24
  ),
25
- submit_btn='Calculate'
 
26
  )
27
 
28
 
 
16
  inputs=[
17
  gr.Textbox(label='Word 1 (required)', placeholder='χρηστήριον'),
18
  gr.Radio(label='Time slice (required)', choices=["archaic_cbow", "classical_cbow", "early_roman_cbow", "hellen_cbow", "late_roman_cbow"]),
19
+ gr.Slider(label='Number of neighbours', minimum=1, maximum=50, step=1)
20
  ],
21
  outputs=gr.DataFrame(
22
  label="Result",
23
+ headers=["Word", "Time slice", "Cosine similarity"],
24
+ type="pandas", visible=True, interactive=False
25
  ),
26
+ submit_btn='Calculate',
27
+
28
  )
29
 
30
 
word2vec.py CHANGED
@@ -159,7 +159,7 @@ def get_nearest_neighbours(word, time_slice_model, n=10, models=load_all_models(
159
  nearest_neighbours.remove(smallest_neighbour)
160
  nearest_neighbours.append((word, model_name, cosine_similarity_vectors))
161
 
162
- return sorted(nearest_neighbours, key=lambda x: x[2], reverse=True)[:10]
163
 
164
 
165
 
 
159
  nearest_neighbours.remove(smallest_neighbour)
160
  nearest_neighbours.append((word, model_name, cosine_similarity_vectors))
161
 
162
+ return sorted(nearest_neighbours, key=lambda x: x[2], reverse=True)
163
 
164
 
165