Spaces:
Runtime error
Runtime error
Update appStore/keyword_search.py
Browse files- 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 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
#docs = pre.load_document(temp.name, file)
|
97 |
|
98 |
# preprocess document
|
99 |
#haystackDoc, dataframeDoc, textData, paraList = clean.preprocessing(docs)
|
100 |
|
101 |
-
|
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
|