abdulllah01 commited on
Commit
336a973
·
verified ·
1 Parent(s): 9ead40f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -11
app.py CHANGED
@@ -32,19 +32,18 @@ def process_matching(keywords, article, fuzzy, mode):
32
  results = {}
33
  max_keyword_length = max(len(k.split()) for k in keywords)
34
 
35
- for n in range(1, max_keyword_length + 1):
36
- n_grams_exact = [" ".join(article_exact.split()[i:i + n]) for i in range(len(article_exact.split()) - n + 1)]
37
- n_grams_fuzzy = [" ".join(article_fuzzy.split()[i:i + n]) for i in range(len(article_fuzzy.split()) - n + 1)]
38
-
39
- for keyword in keywords:
40
- if fuzzy:
41
  matches = process.extract(keyword, n_grams_fuzzy, scorer=fuzz.partial_ratio, limit=None)
42
- if keyword not in results:
43
- results[keyword] = 0
44
  results[keyword] += sum(1 for match, score in matches if score > 90)
45
- else:
46
- if keyword not in results:
47
- results[keyword] = 0
 
 
48
  results[keyword] += n_grams_exact.count(keyword)
49
 
50
  if mode == "filter":
 
32
  results = {}
33
  max_keyword_length = max(len(k.split()) for k in keywords)
34
 
35
+ for keyword in keywords:
36
+ if fuzzy:
37
+ results[keyword] = 0
38
+ for n in range(1, max_keyword_length + 1):
39
+ n_grams_fuzzy = [" ".join(article_fuzzy.split()[i:i + n]) for i in range(len(article_fuzzy.split()) - n + 1)]
 
40
  matches = process.extract(keyword, n_grams_fuzzy, scorer=fuzz.partial_ratio, limit=None)
 
 
41
  results[keyword] += sum(1 for match, score in matches if score > 90)
42
+ else:
43
+ if keyword not in results:
44
+ results[keyword] = 0
45
+ for n in range(1, max_keyword_length + 1):
46
+ n_grams_exact = [" ".join(article_exact.split()[i:i + n]) for i in range(len(article_exact.split()) - n + 1)]
47
  results[keyword] += n_grams_exact.count(keyword)
48
 
49
  if mode == "filter":