ldhldh commited on
Commit
46f6c56
·
verified ·
1 Parent(s): c9f7b9a

Update util/preprocessing.py

Browse files
Files changed (1) hide show
  1. util/preprocessing.py +3 -3
util/preprocessing.py CHANGED
@@ -9,9 +9,6 @@ def word_to_market_name(word):
9
  scores = dict()
10
 
11
  for m in markets_names:
12
- sm = difflib.SequenceMatcher(None, word, m)
13
- scores[m] = sm.ratio()
14
-
15
  flag = True
16
  for c in range(len(word)):
17
  if c < len(m):
@@ -19,6 +16,9 @@ def word_to_market_name(word):
19
  flag = False
20
  if flag:
21
  output.append(m)
 
 
 
22
  sorted_scores = sorted(scores.items(), key=lambda item: item[1], reverse=True)
23
  top_3_markets = [market[0] for market in sorted_scores[:3]]
24
  for i in range(len(top_3_markets)):
 
9
  scores = dict()
10
 
11
  for m in markets_names:
 
 
 
12
  flag = True
13
  for c in range(len(word)):
14
  if c < len(m):
 
16
  flag = False
17
  if flag:
18
  output.append(m)
19
+ else:
20
+ sm = difflib.SequenceMatcher(None, word, m)
21
+ scores[m] = sm.ratio()
22
  sorted_scores = sorted(scores.items(), key=lambda item: item[1], reverse=True)
23
  top_3_markets = [market[0] for market in sorted_scores[:3]]
24
  for i in range(len(top_3_markets)):