YchKhan commited on
Commit
3421540
1 Parent(s): 7abc455

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -63,7 +63,7 @@ def stream_template(template_name, **context):
63
  rv.disable_buffering()
64
  return rv
65
 
66
- def infer(query):
67
  user_samples = split_string(query, 80, 3)
68
  top_k = min(5, len(descriptions))
69
  results = []
@@ -90,16 +90,23 @@ def infer(query):
90
  specs.append(ts)
91
  std.extend(specs)
92
  results.append(sp)
93
- rankings = [{ 'word': 'string', 'freq': 'count/size' }, { 'word': 'string', 'freq': 'count/size' }, { 'word': 'string', 'freq': 'count/size' }, { 'word': 'string', 'freq': 'count/size' }, { 'word': 'string', 'freq': 'count/size' },]
 
94
  #yield render_template('index.html', results=results)#, query=query, rankings=rankings)
95
  #yield results
96
  cpt += 1
97
  print("ranking")
98
  rankings = top_five_strings(std, len(user_samples))
99
  print("ranked")
100
- return render_template('index.html', results=results, query=query, rankings=rankings)
101
-
102
 
 
 
 
 
 
 
 
103
 
104
 
105
  @app.route('/', methods=['GET', 'POST'])
 
63
  rv.disable_buffering()
64
  return rv
65
 
66
+ def infer_gen(query):
67
  user_samples = split_string(query, 80, 3)
68
  top_k = min(5, len(descriptions))
69
  results = []
 
90
  specs.append(ts)
91
  std.extend(specs)
92
  results.append(sp)
93
+ yield results
94
+ #rankings = [{ 'word': 'string', 'freq': 'count/size' }, { 'word': 'string', 'freq': 'count/size' }, { 'word': 'string', 'freq': 'count/size' }, { 'word': 'string', 'freq': 'count/size' }, { 'word': 'string', 'freq': 'count/size' },]
95
  #yield render_template('index.html', results=results)#, query=query, rankings=rankings)
96
  #yield results
97
  cpt += 1
98
  print("ranking")
99
  rankings = top_five_strings(std, len(user_samples))
100
  print("ranked")
101
+ yield render_template('index.html', results=results)#, query=query, rankings=rankings)
 
102
 
103
+ def infer(query):
104
+ gen = infer_gen
105
+ while True:
106
+ try:
107
+ yield str(next(gen))
108
+ except StopIteration:
109
+ return
110
 
111
 
112
  @app.route('/', methods=['GET', 'POST'])