domro11 commited on
Commit
ae4ac63
·
1 Parent(s): 6d55e84

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -16
app.py CHANGED
@@ -24,7 +24,7 @@ def draw_all(
24
  1. Advanced Text Summarizer
25
  2. Key Word Extractor
26
  3. Question Answering
27
- 4. Text Completion
28
 
29
  ```
30
  """
@@ -40,7 +40,7 @@ with st.sidebar:
40
  def main():
41
  st.title("NLP IE Web App")
42
  menu = ["--Select--","Summarizer",
43
- "Keyword Extractor","Question Answering","Text Completion"]
44
  choice = st.sidebar.selectbox("What task would you like to do?", menu)
45
  if choice=="--Select--":
46
 
@@ -120,20 +120,22 @@ def main():
120
  generated_text = '. '.join(list(map(lambda x: x.strip().capitalize(), generated_text.split('.'))))
121
  st.write(f" Here's your Answer :\n {generated_text}")
122
 
123
- elif choice=="Text Completion":
124
- st.subheader("Text Completion")
125
- st.write(" Enter the uncomplete Text to complete it automatically using AI !")
126
- text_generation = pipeline("text-generation")
127
- message = st.text_area("Your Text","Enter the Text to complete")
128
-
129
-
130
- if message !="Enter the Text to complete":
131
- generator = text_generation(message)
132
- s1 = json.dumps(generator[0])
133
- d2 = json.loads(s1)
134
- generated_text = d2['generated_text']
135
- generated_text = '. '.join(list(map(lambda x: x.strip().capitalize(), generated_text.split('.'))))
136
- st.write(f" Here's your Generate Text :\n {generated_text}")
 
 
137
 
138
  #main function to run
139
  if __name__ == '__main__':
 
24
  1. Advanced Text Summarizer
25
  2. Key Word Extractor
26
  3. Question Answering
27
+ 4. Question Generation
28
 
29
  ```
30
  """
 
40
  def main():
41
  st.title("NLP IE Web App")
42
  menu = ["--Select--","Summarizer",
43
+ "Keyword Extractor","Question Answering","Question Generation"]
44
  choice = st.sidebar.selectbox("What task would you like to do?", menu)
45
  if choice=="--Select--":
46
 
 
120
  generated_text = '. '.join(list(map(lambda x: x.strip().capitalize(), generated_text.split('.'))))
121
  st.write(f" Here's your Answer :\n {generated_text}")
122
 
123
+ elif choice=="Question Generation":
124
+ st.subheader("Question Generation")
125
+ st.write(" Enter the text to get questions generated !")
126
+ question_generator = pipeline("question-generation",model="mrm8488/t5-base-finetuned-question-generation-ap",tokenizer="mrm8488/t5-base-finetuned-question-generation-ap"
127
+ text_input2 = st.text_area("Your Text","Enter the Text to complete")
128
+
129
+
130
+ if text_input2:
131
+ # Extract named entities from the text
132
+ entities = extract_entities(text_input2)
133
+ # Generate questions based on the text using the T5 model
134
+ questions = question_generator(text_input2, max_length=30)
135
+ # Display the generated questions
136
+ st.subheader("Generated questions")
137
+ for question in questions:
138
+ st.write(question["question"])
139
 
140
  #main function to run
141
  if __name__ == '__main__':