Fix most_similar call

#5
by map222 - opened
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -20,8 +20,6 @@ recipe_NER = pd.read_csv(cached_download(url), sep='\t' )
20
 
21
  '''
22
 
23
- app = gr.Blocks()
24
-
25
  def get_fusion_ingredients(ingredient: str,
26
  recipe_model, #gensim model
27
  recipes, #iterable of recipes
@@ -45,14 +43,15 @@ def get_fusion_ingredients(ingredient: str,
45
 
46
  def helper_func(text):
47
  #a,b,c = get_fusion_ingredients(x, recipe_w2v, ingredient_count, recipe_NER)
48
- nearest = recipe_w2v.most_similar(text)
49
  return pd.DataFrame(nearest)
50
 
 
 
51
  with app:
52
  gr.Markdown("# Recipe Spice")
53
  with gr.Row():
54
  text_in = gr.Textbox(lines=1, placeholder="Ingredient", label="Search Query")
55
- compute_bt = gr.Button("Search")
56
 
57
 
58
  with gr.Row():
@@ -64,6 +63,6 @@ with app:
64
  This finds cool new recipe stuff
65
  """
66
  )
67
- compute_bt.click(helper_func, inputs=[text_in], outputs=[df_out])
68
 
69
  app.launch()
 
20
 
21
  '''
22
 
 
 
23
  def get_fusion_ingredients(ingredient: str,
24
  recipe_model, #gensim model
25
  recipes, #iterable of recipes
 
43
 
44
  def helper_func(text):
45
  #a,b,c = get_fusion_ingredients(x, recipe_w2v, ingredient_count, recipe_NER)
46
+ nearest = recipe_w2v.wv.most_similar(text)
47
  return pd.DataFrame(nearest)
48
 
49
+ app = gr.Blocks()
50
+
51
  with app:
52
  gr.Markdown("# Recipe Spice")
53
  with gr.Row():
54
  text_in = gr.Textbox(lines=1, placeholder="Ingredient", label="Search Query")
 
55
 
56
 
57
  with gr.Row():
 
63
  This finds cool new recipe stuff
64
  """
65
  )
66
+ text_in.submit(helper_func, inputs=[text_in], outputs=[df_out])
67
 
68
  app.launch()