M17idd commited on
Commit
9a43318
·
1 Parent(s): 90339ff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -584,7 +584,7 @@ def summarize_text_by_frequency(text, num_sentences=3):
584
 
585
 
586
 
587
- def find_closest_lines(query, doc_texts, stop_words, top_n=10):
588
  cleaned_query = remove_stop_words(query, stop_words)
589
  query_words = cleaned_query.split()
590
 
@@ -611,14 +611,14 @@ def remove_stop_words_from_lines(lines, stop_words):
611
  return cleaned_lines
612
 
613
  if query:
614
- closest_lines = find_closest_lines(query, doc_texts, stop_words, top_n=10)
615
 
616
  # حذف استپ‌وردها از خطوط و سپس پاکسازی نهایی متن
617
  cleaned_closest_lines = [
618
  clean_text(" ".join([word for word in line.split() if word not in stop_words]))
619
  for line in closest_lines
620
  ]
621
- summarized_text = summarize_text_by_frequency("\n".join(cleaned_closest_lines), num_sentences=1)
622
  summarized_cleaned = " ".join([
623
  word for word in summarized_text.split()
624
  if word not in stop_words
@@ -629,7 +629,7 @@ if query:
629
  # cleaned_text = "\n".join(cleaned_closest_lines[:1])
630
 
631
  prompt = f"""
632
- لطفاً با توجه به سؤال زیر و محتوای خطوط مرتبط، یک پاسخ نهایی حرفه‌ای، دقیق و روان تولید کن. فقط از متن خطوط مرتبط استفاده کن. اگر اطلاعات کافی در متن وجود ندارد، صادقانه اعلام کن.
633
  سوال:
634
  {query}
635
  خطوط مرتبط:
 
584
 
585
 
586
 
587
+ def find_closest_lines(query, doc_texts, stop_words, top_n=5):
588
  cleaned_query = remove_stop_words(query, stop_words)
589
  query_words = cleaned_query.split()
590
 
 
611
  return cleaned_lines
612
 
613
  if query:
614
+ closest_lines = find_closest_lines(query, doc_texts, stop_words, top_n=5)
615
 
616
  # حذف استپ‌وردها از خطوط و سپس پاکسازی نهایی متن
617
  cleaned_closest_lines = [
618
  clean_text(" ".join([word for word in line.split() if word not in stop_words]))
619
  for line in closest_lines
620
  ]
621
+ summarized_text = summarize_text_by_frequency("\n".join(cleaned_closest_lines), num_sentences=3)
622
  summarized_cleaned = " ".join([
623
  word for word in summarized_text.split()
624
  if word not in stop_words
 
629
  # cleaned_text = "\n".join(cleaned_closest_lines[:1])
630
 
631
  prompt = f"""
632
+ لطفاً با توجه به سؤال زیر و محتوای خطوط مرتبط، یک پاسخ نهایی حرفه‌ای، دقیق و روان تولید کن. فقط از متن خطوط مرتبط استفاده کن و خلاصه بنویس و اضافه ننویس فقط به سوال جواب بده از متن خطوط مرتبط. اگر اطلاعات کافی در متن وجود ندارد، صادقانه اعلام کن.
633
  سوال:
634
  {query}
635
  خطوط مرتبط: