Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -33,15 +33,15 @@ def process_matching(keywords, article, fuzzy, mode):
|
|
33 |
max_keyword_length = max(len(k.split()) for k in keywords)
|
34 |
|
35 |
for keyword in keywords:
|
36 |
-
if
|
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)
|
|
|
33 |
max_keyword_length = max(len(k.split()) for k in keywords)
|
34 |
|
35 |
for keyword in keywords:
|
36 |
+
if keyword not in results:
|
37 |
results[keyword] = 0
|
38 |
+
|
39 |
+
if fuzzy:
|
40 |
for n in range(1, max_keyword_length + 1):
|
41 |
n_grams_fuzzy = [" ".join(article_fuzzy.split()[i:i + n]) for i in range(len(article_fuzzy.split()) - n + 1)]
|
42 |
matches = process.extract(keyword, n_grams_fuzzy, scorer=fuzz.partial_ratio, limit=None)
|
43 |
results[keyword] += sum(1 for match, score in matches if score > 90)
|
44 |
else:
|
|
|
|
|
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)
|