Update app.py
Browse files
app.py
CHANGED
@@ -594,7 +594,7 @@ def find_closest_lines(query, doc_texts, stop_words, top_n=10):
|
|
594 |
for filename, text in doc_texts.items():
|
595 |
matched_lines = extract_keywords_from_text(text, query_words)
|
596 |
for line in matched_lines:
|
597 |
-
similarity = fuzz.partial_ratio(query, line)
|
598 |
all_matched_lines.append((line, similarity))
|
599 |
|
600 |
all_matched_lines.sort(key=lambda x: x[1], reverse=True)
|
@@ -612,14 +612,14 @@ def remove_stop_words_from_lines(lines, stop_words):
|
|
612 |
return cleaned_lines
|
613 |
|
614 |
if query:
|
615 |
-
closest_lines = find_closest_lines(query, doc_texts, stop_words, top_n=
|
616 |
|
617 |
# حذف استپوردها از خطوط و سپس پاکسازی نهایی متن
|
618 |
cleaned_closest_lines = [
|
619 |
clean_text(" ".join([word for word in line.split() if word not in stop_words]))
|
620 |
for line in closest_lines
|
621 |
]
|
622 |
-
summarized_text = summarize_text_by_frequency("\n".join(cleaned_closest_lines), num_sentences=
|
623 |
|
624 |
|
625 |
if summarized_text:
|
|
|
594 |
for filename, text in doc_texts.items():
|
595 |
matched_lines = extract_keywords_from_text(text, query_words)
|
596 |
for line in matched_lines:
|
597 |
+
similarity = fuzz.partial_ratio(query, line)
|
598 |
all_matched_lines.append((line, similarity))
|
599 |
|
600 |
all_matched_lines.sort(key=lambda x: x[1], reverse=True)
|
|
|
612 |
return cleaned_lines
|
613 |
|
614 |
if query:
|
615 |
+
closest_lines = find_closest_lines(query, doc_texts, stop_words, top_n=5)
|
616 |
|
617 |
# حذف استپوردها از خطوط و سپس پاکسازی نهایی متن
|
618 |
cleaned_closest_lines = [
|
619 |
clean_text(" ".join([word for word in line.split() if word not in stop_words]))
|
620 |
for line in closest_lines
|
621 |
]
|
622 |
+
summarized_text = summarize_text_by_frequency("\n".join(cleaned_closest_lines), num_sentences=3)
|
623 |
|
624 |
|
625 |
if summarized_text:
|