Vipul-Chauhan commited on
Commit
55e37de
1 Parent(s): 1e35828

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -0
app.py CHANGED
@@ -137,14 +137,18 @@ def cosine_similarity(a,b):
137
 
138
  def return_selected_cluster(ques):
139
  ques_clean = process_row(ques)
 
140
  cluster_selected =-1
141
  cluster_score =0
142
  for clus_id in dictt_cluster_words:
143
  score_temp=0
 
144
  for word in ques_clean.split():
145
  dictt_temp = dictt_cluster_words[clus_id]
146
  if word in dictt_temp:
 
147
  score_temp+=dictt_temp[word]
 
148
  if score_temp>cluster_score:
149
  cluster_selected = clus_id
150
  cluster_score = score_temp
 
137
 
138
  def return_selected_cluster(ques):
139
  ques_clean = process_row(ques)
140
+ count_tokens = len(ques_clean.split())
141
  cluster_selected =-1
142
  cluster_score =0
143
  for clus_id in dictt_cluster_words:
144
  score_temp=0
145
+ matched_token=0
146
  for word in ques_clean.split():
147
  dictt_temp = dictt_cluster_words[clus_id]
148
  if word in dictt_temp:
149
+ matched_token+=1
150
  score_temp+=dictt_temp[word]
151
+ score_temp*= (matched_token/count_tokens)
152
  if score_temp>cluster_score:
153
  cluster_selected = clus_id
154
  cluster_score = score_temp