Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 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 |
-
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
| 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":
|