Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -68,7 +68,72 @@ def extract_and_paragraph(pdf1, pdf2, paragraph):
|
|
| 68 |
|
| 69 |
# Gradio interface setup
|
| 70 |
PDF_FOLDER = "data"
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
def get_pdf_files(folder):
|
| 73 |
return [f for f in os.listdir(folder) if f.endswith('.pdf')]
|
| 74 |
|
|
|
|
| 68 |
|
| 69 |
# Gradio interface setup
|
| 70 |
PDF_FOLDER = "data"
|
| 71 |
+
def process_paragraph_1_sum(paragraph):
|
| 72 |
+
try:
|
| 73 |
+
paragraph_index = int(paragraph.split(':')[0].replace('Paragraph ', '')) - 1
|
| 74 |
+
selected_paragraph = stored_paragraphs_1[paragraph_index]
|
| 75 |
+
summary = summarize_text(selected_paragraph)
|
| 76 |
+
return summary
|
| 77 |
+
except (IndexError, ValueError):
|
| 78 |
+
return "Error"
|
| 79 |
+
def process_paragraph_1_sent(paragraph):
|
| 80 |
+
try:
|
| 81 |
+
paragraph_index = int(paragraph.split(':')[0].replace('Paragraph ', '')) - 1
|
| 82 |
+
selected_paragraph = stored_paragraphs_1[paragraph_index]
|
| 83 |
+
sentiment = text_to_sentiment(selected_paragraph)
|
| 84 |
+
|
| 85 |
+
return sentiment
|
| 86 |
+
except (IndexError, ValueError):
|
| 87 |
+
return "Error"
|
| 88 |
+
def process_paragraph_1_sent_tone(paragraph):
|
| 89 |
+
try:
|
| 90 |
+
paragraph_index = int(paragraph.split(':')[0].replace('Paragraph ', '')) - 1
|
| 91 |
+
selected_paragraph = stored_paragraphs_1[paragraph_index]
|
| 92 |
+
fin_spans = fin_ext(selected_paragraph)
|
| 93 |
+
return fin_spans
|
| 94 |
+
except (IndexError, ValueError):
|
| 95 |
+
return []
|
| 96 |
+
def process_paragraph_1_sent_tone_bis(paragraph):
|
| 97 |
+
try:
|
| 98 |
+
paragraph_index = int(paragraph.split(':')[0].replace('Paragraph ', '')) - 1
|
| 99 |
+
selected_paragraph = stored_paragraphs_1[paragraph_index]
|
| 100 |
+
fin_spans = fin_ext_bis(selected_paragraph)
|
| 101 |
+
return fin_spans
|
| 102 |
+
except (IndexError, ValueError):
|
| 103 |
+
return []
|
| 104 |
+
def process_paragraph_2_sum(paragraph):
|
| 105 |
+
try:
|
| 106 |
+
paragraph_index = int(paragraph.split(':')[0].replace('Paragraph ', '')) - 1
|
| 107 |
+
selected_paragraph = stored_paragraphs_2[paragraph_index]
|
| 108 |
+
summary = summarize_text(selected_paragraph)
|
| 109 |
+
return summary
|
| 110 |
+
except (IndexError, ValueError):
|
| 111 |
+
return "Error"
|
| 112 |
+
def process_paragraph_2_sent(paragraph):
|
| 113 |
+
try:
|
| 114 |
+
paragraph_index = int(paragraph.split(':')[0].replace('Paragraph ', '')) - 1
|
| 115 |
+
selected_paragraph = stored_paragraphs_2[paragraph_index]
|
| 116 |
+
sentiment = text_to_sentiment(selected_paragraph)
|
| 117 |
+
|
| 118 |
+
return sentiment
|
| 119 |
+
except (IndexError, ValueError):
|
| 120 |
+
return "Error"
|
| 121 |
+
def process_paragraph_2_sent_tone(paragraph):
|
| 122 |
+
try:
|
| 123 |
+
paragraph_index = int(paragraph.split(':')[0].replace('Paragraph ', '')) - 1
|
| 124 |
+
selected_paragraph = stored_paragraphs_2[paragraph_index]
|
| 125 |
+
fin_spans = fin_ext(selected_paragraph)
|
| 126 |
+
return fin_spans
|
| 127 |
+
except (IndexError, ValueError):
|
| 128 |
+
return []
|
| 129 |
+
def process_paragraph_2_sent_tone_bis(paragraph):
|
| 130 |
+
try:
|
| 131 |
+
paragraph_index = int(paragraph.split(':')[0].replace('Paragraph ', '')) - 1
|
| 132 |
+
selected_paragraph = stored_paragraphs_2[paragraph_index]
|
| 133 |
+
fin_spans = fin_ext_bis(selected_paragraph)
|
| 134 |
+
return fin_spans
|
| 135 |
+
except (IndexError, ValueError):
|
| 136 |
+
return []
|
| 137 |
def get_pdf_files(folder):
|
| 138 |
return [f for f in os.listdir(folder) if f.endswith('.pdf')]
|
| 139 |
|