peter2000 commited on
Commit
9aad845
β€’
1 Parent(s): df53ec6

Update appStore/keyword_search.py

Browse files
Files changed (1) hide show
  1. appStore/keyword_search.py +19 -16
appStore/keyword_search.py CHANGED
@@ -79,30 +79,33 @@ def app():
79
  #st.markdown("## πŸ“Œ Step One: Upload document ")
80
 
81
  with st.container():
 
 
 
 
82
  #file = st.file_uploader('Upload PDF File', type=['pdf', 'docx', 'txt'])
83
- if file is not None:
84
- with tempfile.NamedTemporaryFile(mode="wb") as temp:
85
- bytes_data = file.getvalue()
86
- temp.write(bytes_data)
87
- file_name = file.name
88
- file_path = temp.name
89
-
90
- st.write("Filename: ", file.name)
91
-
92
- # load document
93
- documents = pre.load_document(temp.name,file_name)
94
- documents_processed = pre.preprocessing(documents)
95
- pipeline = start_haystack(documents_processed)
96
  #docs = pre.load_document(temp.name, file)
97
 
98
  # preprocess document
99
  #haystackDoc, dataframeDoc, textData, paraList = clean.preprocessing(docs)
100
 
101
- question = st.text_input("Please enter your question here, we will look for the answer in the document.",
102
- value="floods",)
103
 
104
 
105
- if st.button("Find them."):
106
  with st.spinner("πŸ‘‘ Performing semantic search on"):#+file.name+"..."):
107
  try:
108
  msg = 'Asked ' + question
 
79
  #st.markdown("## πŸ“Œ Step One: Upload document ")
80
 
81
  with st.container():
82
+ file = st.SessionState['file']
83
+ question = st.text_input("Please enter your question here, we will look for the answer in the document.",
84
+ value="What particular risks does climate change pose for women?",)
85
+ if st.button("Find them."):
86
  #file = st.file_uploader('Upload PDF File', type=['pdf', 'docx', 'txt'])
87
+ if file is not None:
88
+ with tempfile.NamedTemporaryFile(mode="wb") as temp:
89
+ bytes_data = file.getvalue()
90
+ temp.write(bytes_data)
91
+ file_name = file.name
92
+ file_path = temp.name
93
+
94
+ st.write("Filename: ", file.name)
95
+
96
+ # load document
97
+ documents = pre.load_document(temp.name,file_name)
98
+ documents_processed = pre.preprocessing(documents)
99
+ pipeline = start_haystack(documents_processed)
100
  #docs = pre.load_document(temp.name, file)
101
 
102
  # preprocess document
103
  #haystackDoc, dataframeDoc, textData, paraList = clean.preprocessing(docs)
104
 
105
+
 
106
 
107
 
108
+ #if st.button("Find them."):
109
  with st.spinner("πŸ‘‘ Performing semantic search on"):#+file.name+"..."):
110
  try:
111
  msg = 'Asked ' + question