Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def upload_file():
- try :
- return render_template('upload.html')
- except Exception as e :
- logging.warning(str(e))
- result_dict={"error":str(e)}
- return jsonify(result_dict)
- @app.route('/uploader', methods = ['GET', 'POST'])
- def upload_file1():
- global w2v_model
- try:
- #w2v_model = session.get('w2v_model', None)
- if request.method == 'POST':
- file_id = '1-jLh3Zdi-gwIFEnrw0VKQnoLH8mof2hN'
- destination = os.getcwd()+"//search_strings.docx"
- download_file_from_google_drive(file_id, destination)
- f1 = request.files['file1']
- f1.save(secure_filename(f1.filename.replace(" ", "_")))
- #f2 = request.files['file2']
- #f2.save(secure_filename(f2.filename.replace(" ", "_")))
- logging.warning (f1.filename.replace(" ", "_"),w2v_model)
- questions,answers,results,flag=search_new.main(f1.filename.replace(" ", "_"),"search_strings.docx",w2v_model)
- if (flag):
- return jsonify({'error':"Documents with .doc extensions are not supported"})
- result_dict={}
- i=1
- for item1 , item2,item3 in zip (questions,answers,results):
- result_dict['{0}_question'.format(i)]=str(item1)
- result_dict['{0}_answer'.format(i)]=str(item2)
- j=1
- for item in item3 :
- result_dict['{0}_{1}_coinfidence'.format(i,j)]=str(item[1])
- result_dict['{0}_{1}_paragraph'.format(i,j)]=str(item[0])
- j+=1
- i+=1
- except Exception as e :
- result_dict={"error":str(e)}
- #return jsonify(result_dict)
- import pandas as pd
- data = [jsonify(result_dict)]
- df = pd.DataFrame.from_dict(data, orient='columns')
- #print(result_dict)
Add Comment
Please, Sign In to add comment