domro11 commited on
Commit
83f1609
·
1 Parent(s): f8c9f63

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -13
app.py CHANGED
@@ -5,12 +5,8 @@ import pandas as pd
5
  from transformers import pipeline
6
  import json
7
 
8
- import os
9
 
10
- # Create a new directory
11
- directory_name = "documents"
12
- if not os.path.exists(directory_name):
13
- os.makedirs(directory_name)
14
 
15
 
16
 
@@ -70,19 +66,22 @@ def main():
70
 
71
 
72
  st.image('banner_image.jpg')
73
-
 
 
 
74
 
75
 
76
  elif choice=="Summarizer":
77
  st.subheader("Text Summarization")
78
  st.write(" Enter the Text you want to summarize !")
79
- documents = {
80
- "Document 1": "This is the text for document 1.",
81
- "Document 2": "This is the text for document 2.",
82
- "Document 3": "This is the text for document 3."
83
- }
84
- document_name = st.selectbox("Select a document", list(documents.keys()))
85
- raw_text = documents[document_name]
86
  num_words = st.number_input("Enter Number of Words in Summary")
87
 
88
  if raw_text!="" and num_words is not None:
 
5
  from transformers import pipeline
6
  import json
7
 
8
+ from datasets import load_dataset
9
 
 
 
 
 
10
 
11
 
12
 
 
66
 
67
 
68
  st.image('banner_image.jpg')
69
+
70
+
71
+
72
+
73
 
74
 
75
  elif choice=="Summarizer":
76
  st.subheader("Text Summarization")
77
  st.write(" Enter the Text you want to summarize !")
78
+ # Create a dropdown to select which document to read
79
+ document_names = [str(document['id']) for document in dataset['documents']]
80
+ document_to_read = st.selectbox("Select a document to read", document_names)
81
+ # Read the selected document
82
+ selected_document = dataset['documents'][int(document_to_read)]
83
+ document_text = selected_document['text']
84
+ raw_text = documents[document_text]
85
  num_words = st.number_input("Enter Number of Words in Summary")
86
 
87
  if raw_text!="" and num_words is not None: