<commit_before>"""AUTHOR      : <NAME>
   INSTITUTION : NIT Jalandhar"""

import os
from flask import *
from werkzeug import secure_filename
import csv
from py2neo import *
import time
from nltk.tokenize import word_tokenize
from nltk.corpus import stopwords

ALLOWED_EXTENSIONS = set(['csv'])
UPLOAD_FOLDER="C:/Users/<NAME>/Documents/Neo4j/Ticketanalysisdb/import/"

app=Flask(__name__)
app.secret_key = 'random string'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER

def allowed_files(filename):
    return '.' in filename and \
           filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS

@app.route('/')
def home():
    return render_template('homepage.html')

@app.route('/alreadyuploaded/',methods=['post'])
def alreadyuploaded():
	passw=request.form["password"]
	gr=Graph(password=<PASSWORD>w)
	tx=gr.begin()
	a=Node("suggestions",query="Dummy")
	tx.merge(a)
	tx.commit()
	queries=gr.run("match (a:suggestions) return a.query").data()
	#print(queries)
	suggestions=[i["a.query"] for i in queries] 
	return render_template('resultspage.html',contenttype=".csv",tm=0,passval=passw,suggestions=suggestions)

@app.route('/results/',methods=['post'])
def results():
	file=request.files['file']
	if file.filename=='':
		flash("No file was selected !!")
		flash("Choose your file again")
		return redirect(url_for("home"))
	elif not allowed_files(file.filename):
		flash("Invalid file (Only .csv (UTF-8) allowed)!!")
		flash("Choose your file again")
		return redirect(url_for("home"))
	else:
		st=time.time()
		passw=request.form['pass']
		gr=Graph(password=passw)
		securedfile=secure_filename(file.filename)

		if not os.path.exists(UPLOAD_FOLDER):
			os.makedirs(UPLOAD_FOLDER)

		file.save(os.path.join(app.config['UPLOAD_FOLDER'], securedfile))

		ctype=file.content_type

		rqidlist=set()
		itolist=set()
		dolist=set()

		with open('C:\\Users\\<NAME>\\Documents\\Neo4j\\Ticketanalysisdb\\import\\'+securedfile) as csvfile:
			reader = csv.DictReader(csvfile)
			for row in reader:
				tt=row['Ticket_Type']
				sv=row['Severity']
				rqid=int(row['Requester_ID'])<commit_msg>tested2<commit_after>"""AUTHOR      : <NAME>
   INSTITUTION : NIT Jalandhar"""

import os
from flask import *
from werkzeug import secure_filename
import csv
from py2neo import *
import time
from nltk.tokenize import word_tokenize
from nltk.corpus import stopwords

ALLOWED_EXTENSIONS = set(['csv'])

app=Flask(__name__)
app.secret_key = 'random string'

def allowed_files(filename):
    return '.' in filename and \
           filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS

@app.route('/')
def home():
    return render_template('homepage.html')

@app.route('/alreadyuploaded/',methods=['post'])
def alreadyuploaded():
	passw=request.form["password"]
	gr=Graph(password=passw)
	tx=gr.begin()
	a=Node("suggestions",query="Dummy")
	tx.merge(a)
	tx.commit()
	queries=gr.run("match (a:suggestions) return a.query").data()
	#print(queries)
	suggestions=[i["a.query"] for i in queries] 
	return render_template('resultspage.html',contenttype=".csv",tm=0,passval=passw,suggestions=suggestions)

@app.route('/results/',methods=['post'])
def results():
	file=request.files['file']
	if file.filename=='':
		flash("No file was selected !!")
		flash("Choose your file again")
		return redirect(url_for("home"))
	elif not allowed_files(file.filename):
		flash("Invalid file (Only .csv (UTF-8) allowed)!!")
		flash("Choose your file again")
		return redirect(url_for("home"))
	else:
		st=time.time()
		passw=request.form['pass']
		adid=request.form['adid'].strip().upper()
		UPLOAD_FOLDER="C:/Users/"+adid+"/Documents/Neo4j/Ticketanalysisdb/import/"
		app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
		gr=Graph(password=<PASSWORD>)
		securedfile=secure_filename(file.filename)

		if not os.path.exists(UPLOAD_FOLDER):
			os.makedirs(UPLOAD_FOLDER)

		file.save(os.path.join(app.config['UPLOAD_FOLDER'], securedfile))

		ctype=file.content_type

		rqidlist=set()
		itolist=set()
		dolist=set()

		with open('C:\\Users\\'+adid+'\\Documents\\Neo4j\\Ticketanalysisdb\\import\\'+securedfile) as csvfile:
			reader = csv.DictReader(csvfile)
			for row in reader:
				tt=row['Ticket_Type']
				sv=row['Severity']
				rqid=int(row['Requester_ID'])
{'fraction_non_alphanumeric': 0.16441601516228382, 'fraction_numerical': 0.0035536602700781805, 'mean_word_length': 5.525502318392581, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2577180', 'n_tokens_mistral': 1629, 'n_tokens_neox': 1529, 'n_words': 266}