Update app.py
Browse files
app.py
CHANGED
@@ -568,7 +568,7 @@ def clean_text(text):
|
|
568 |
from collections import Counter
|
569 |
import heapq
|
570 |
|
571 |
-
def summarize_text_by_frequency(text, num_sentences=
|
572 |
sentences = text.split('\n')
|
573 |
word_freq = Counter()
|
574 |
|
@@ -590,7 +590,7 @@ def summarize_text_by_frequency(text, num_sentences=3):
|
|
590 |
|
591 |
|
592 |
|
593 |
-
def find_closest_lines(query, doc_texts, stop_words, top_n=
|
594 |
cleaned_query = remove_stop_words(query, stop_words)
|
595 |
query_words = cleaned_query.split()
|
596 |
|
@@ -617,14 +617,14 @@ def remove_stop_words_from_lines(lines, stop_words):
|
|
617 |
return cleaned_lines
|
618 |
|
619 |
if query:
|
620 |
-
closest_lines = find_closest_lines(query, doc_texts, stop_words, top_n=
|
621 |
|
622 |
# حذف استپوردها از خطوط و سپس پاکسازی نهایی متن
|
623 |
cleaned_closest_lines = [
|
624 |
clean_text(" ".join([word for word in line.split() if word not in stop_words]))
|
625 |
for line in closest_lines
|
626 |
]
|
627 |
-
summarized_text = summarize_text_by_frequency("\n".join(cleaned_closest_lines), num_sentences=
|
628 |
summarized_cleaned = " ".join([word for word in summarized_text.split() if word not in stop_words])
|
629 |
|
630 |
if summarized_text:
|
|
|
568 |
from collections import Counter
|
569 |
import heapq
|
570 |
|
571 |
+
def summarize_text_by_frequency(text, num_sentences=1):
|
572 |
sentences = text.split('\n')
|
573 |
word_freq = Counter()
|
574 |
|
|
|
590 |
|
591 |
|
592 |
|
593 |
+
def find_closest_lines(query, doc_texts, stop_words, top_n=15):
|
594 |
cleaned_query = remove_stop_words(query, stop_words)
|
595 |
query_words = cleaned_query.split()
|
596 |
|
|
|
617 |
return cleaned_lines
|
618 |
|
619 |
if query:
|
620 |
+
closest_lines = find_closest_lines(query, doc_texts, stop_words, top_n=15)
|
621 |
|
622 |
# حذف استپوردها از خطوط و سپس پاکسازی نهایی متن
|
623 |
cleaned_closest_lines = [
|
624 |
clean_text(" ".join([word for word in line.split() if word not in stop_words]))
|
625 |
for line in closest_lines
|
626 |
]
|
627 |
+
summarized_text = summarize_text_by_frequency("\n".join(cleaned_closest_lines), num_sentences=1)
|
628 |
summarized_cleaned = " ".join([word for word in summarized_text.split() if word not in stop_words])
|
629 |
|
630 |
if summarized_text:
|