def evaluate(): if 'file1' not in request.files and 'file2' not in request.files: flash('No file part') return redirect(request.url) file = request.files['file1'] file1 = request.files['file2'] act_txt = get_text(file) que_txt = get_text(file1) score = get_eval(act_txt, que_txt) return {'act_text': act_txt, 'que_text': que_txt, 'percentage': score[0], 'marks': score[1]}
def plagarism(): if 'file1' not in request.files or 'file2' not in request.files: flash('No file part') return redirect(request.url) file = request.files['file1'] file1 = request.files['file2'] act_txt = get_text(file) que_txt = get_text(file1) sim_score = get_similarity_score(act_txt, que_txt) return {"act_text": act_txt, "que_text": que_txt, "similar": sim_score}
def upload_file(): if request.method == 'POST': # check if the post request has the file part if 'file' not in request.files: flash('No file part') return redirect(request.url) file = request.files['file'] file1 = request.files['file1'] if file.filename == '': flash('No file selected for uploading') return redirect(request.url) if file and allowed_file(file.filename): filename = secure_filename(file.filename) file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) act_txt = get_text(file) flash('File successfully uploaded') if file1.filename == '': flash('No file selected for uploading') return redirect(request.url) if file1 and allowed_file(file1.filename): filename = secure_filename(file1.filename) file1.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) que_txt = get_text(file1) flash('File successfully uploaded') sim_score = get_similarity_score(act_txt, que_txt) return render_template("doc_sim.html", act_text=act_txt, que_text=que_txt, similar=sim_score) else: flash('Allowed file types are txt, pdf, png, jpg, jpeg, gif') return redirect(request.url)
def summary(): if 'file' not in request.files: return {"data": "none"} file = request.files['file'] ext_txt = get_text(file) summary = top_sentence(ext_txt, 2) vocab_dict, arr = kmd.textProcessing(ext_txt) tf = kmd.computeTF(vocab_dict, arr) idf = kmd.computeIDF([vocab_dict]) tfidf = kmd.computeTfidf(tf, idf) keyword_ext = tfidf return {"value": ext_txt, "summary_text": summary, "keywords": keyword_ext}
def upload_file(): if request.method == 'POST': # check if the post request has the file part if 'file' not in request.files: flash('No file part') return redirect(request.url) file = request.files['file'] if file.filename == '': flash('No file selected for uploading') return redirect(request.url) if file and allowed_file(file.filename): filename = secure_filename(file.filename) file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) ext_txt = get_text(file) summary = top_sentence(ext_txt, 2) vocab_dict, arr = kmd.textProcessing(ext_txt) tf = kmd.computeTF(vocab_dict, arr) idf = kmd.computeIDF([vocab_dict]) tfidf = kmd.computeTfidf(tf, idf) keyword_ext = tfidf flash('File successfully uploaded') return render_template("index.html", value=ext_txt, summary_text=summary, keywords=keyword_ext) else: flash('Allowed file types are txt, pdf, png, jpg, jpeg, gif') return redirect(request.url)