Example #1
0
def personality_insight(dicto,email):
    db=crud()
    new_dicto={}
    flag=0
    for i in dicto:
        if i["trait_name"] == "Openness" and (i["percentile"] > 0.55 and i["percentile"] < 0.9):
            flag +=1
        elif i["trait_name"] == "Conscientiousness" and (i["percentile"] > 0.5 and i["percentile"] < 0.9) :
            flag +=1
        elif i["trait_name"] == "Extraversion" and (i["percentile"] >0.45 and i["percentile"] < 0.85) :
            flag +=1
        elif i["trait_name"]=="Agreeableness" and (i["percentile"]>0.40 and i["percentile"]<0.85) :
            flag +=1
        elif i["trait_name"]=="Emotional range" and (i["percentile"]>0.40 and i["percentile"]<0.75) :
            flag +=1
    if flag >= 4:
        new_dicto = {"Personality": dicto}
        db.search_and_insert(email,'candidate_features',new_dicto,"single")
        rest = "Congratulations!, you have been shortlisted for the interview process, further information will be mailed to you."
        return rest
    else:
        new_dicto = {"Personality": dicto}
        db.search_and_insert(email,'candidate_features',new_dicto,"single")
        rest = "We regret to inform you that you were not shortlisted for the job, we hope you find success in your life, Thank you."
        return rest
Example #2
0
def hobbi_scoring(score,username):
    db = crud()
    dicto = {}
    dicto = db.search_feature(username, 'candidate_features')
    hobbi = dicto["Hobbies"]
    score = score+len(hobbi)*30
    return score
Example #3
0
def achievement_scoring(score,username):
    db = crud()
    dicto = {}
    dicto = db.search_feature(username, 'candidate_features')
    achivement = dicto["Achievement"]
    score = score+len(achivement)*50
    return score
Example #4
0
def gettestdata(key, dbname, c):
    db = crud()
    doc = db.search_feature(key, 'test_question')
    print(type(doc))
    print(doc)
    l = doc['questions']
    shuffled_doc = random.sample(l, k=c)
    doc = shuffled_doc

    return doc
Example #5
0
def score_skills(score,username):
    db=crud()
    dicto={}
    dicto = db.search_feature(username, 'candidate_features')
    skill = ["c", "cpp", "c++", "java", "python","SQL"]



    skills=dicto["Skill"]

    for i in skills:
        if i.lower() in skill:
            score=score+100
        else:
            score = score+200
    return score
Example #6
0
def score_internships(score,username):
    db = crud()
    companies1 = ['amazon','google','iisc','microsoft','apple']
    companies2 = ['tcs','wipro','infosys','mindtree','l&t infotec']
    intern = {}
    dicto = {}
    company =[]
    dicto = db.search_feature(username,'candidate_features')
    intern = dicto["Internship"]
    for i in intern:
        company.append(list(i.keys())[0])
    for i in company:
        if i.lower() in companies1:
            score = score+300
        elif i.lower() in companies2:
            score = score+200
        else:
            score = score+100
    return score
Example #7
0
def project_scoring(score,username):
    db = crud()
    proj={}
    dicto={}
    tecnologies1 = ["ai","ml","deep learning","neural network","clojure"]
    tecnologies2 = ["flask","django","node js","angular js","react js","ruby","R"]
    dicto = db.search_feature(username,'candidate_features')
    proj = dicto["Project"]
    for i in proj:
        tech = list(i.values())
        print(tech)
        tech = tech[0][0].split(",")
        for j in tech:
            if j.lower() in tecnologies1:
                score=score+300
            elif j.lower() in tecnologies2:
                score=score+200
            else:
                score=score+100
    return score
Example #8
0
    def second_conversation(self, data, email):

        assistant = wh.get_assistant()
        db = crud()
        result_dict = {}
        context = {
                   "skills": {
                       "main skill": {
                           "user_defined": {
                               "flag": 1,
                           }
                       }
                   }
                }
        response, contextvariable = wh.watson_request(data['session_id'], assistant,
                                                     data['message'], context)
        print(contextvariable)
        if (('second_round_flag' in contextvariable.keys()) and ('cand_result' not in contextvariable.keys())):
            data1 = unpack_response(response, data)
            print("In if")
            return(data1)


        elif(('second_round_flag' in contextvariable.keys()) and ('hr1' in contextvariable['cand_result'].keys())):
            ans = contextvariable['cand_result']['hr1']
            result = {'ans1':ans}
            print(result)
            db.search_and_insert(email,'hr_question',result, flag='single')
            data1 = unpack_response(response, data)
            return(data1)

        elif(('second_round_flag' in contextvariable) and ('hr2' in contextvariable['cand_result'])):
            ans = contextvariable['cand_result']['hr2']
            result = {'ans2': ans}
            db.search_and_insert(email, 'hr_question', result, flag = 'single')
            data1 = unpack_response(response, data)
            return(data1)

        elif(('second_round_flag' in contextvariable) and ('hr3' in contextvariable['cand_result'])):
            ans = contextvariable['cand_result']['hr3']
            result = {'ans3': ans}
            db.search_and_insert(email, 'hr_question', result, flag = 'single')
            data1 = unpack_response(response, data)
            return(data1)

        elif(('second_round_flag' in contextvariable) and ('hr4' in contextvariable['cand_result'])):
            ans = contextvariable['cand_result']['hr4']
            result = {'ans4': ans}
            db.search_and_insert(email, 'hr_question', result, flag = 'single')
            data1 = unpack_response(response, data)
            return(data1)

        elif(('second_round_flag' in contextvariable) and ('hr5' in contextvariable['cand_result'])):
            ans = contextvariable['cand_result']['hr5']
            result = {'ans5': ans}
            db.search_and_insert(email, 'hr_question', result, flag = 'single')
            data1 = unpack_response(response, data)
            return(data1)

        elif(('second_round_flag' in contextvariable) and ('hr6' in contextvariable['cand_result'])):
            ans = contextvariable['cand_result']['hr6']
            result = {'ans6': ans}
            db.search_and_insert(email, 'hr_question', result, flag = 'single')
            data1 = unpack_response(response, data)
            return(data1)

        else:
            data1 = unpack_response(response, data)
            return(data1)
            print("In else")
Example #9
0
    def server_convo_handler(self, data, email):
        assistant = wh.get_assistant()
        db = crud()
        result_dict = {}
        db_doc = db.search_feature(email, 'candidate_features')
        context = {
                   "skills":{
                       "main skill": {
                           "user_defined": {
                               "flag": 1,
                               "first_round_flag": db_doc['first_round_flag'],
                               'test_link_share':db_doc['test_link_share']
                           }
                       }
                   }
        }

        response, contextvariable = wh.watson_request(data['session_id'], assistant,
                                                    data['message'], context)

        if 'dob' not in contextvariable.keys():
            data1 = unpack_response(response, data)
            return(data1)

        elif ('dob' in contextvariable.keys()) and ('cand_result' not in contextvariable.keys()):
            dob = contextvariable['dob']
            result = {'dob': dob}
            db.search_and_insert(email, 'candidate_features', result, 'single')
            data1 = unpack_response(response, data)
            return data1

        elif ('dob' in contextvariable.keys()) and ('10th' in contextvariable['cand_result']):
            result = e.split_and_compile(contextvariable['cand_result']['10th'])
            for index, val in enumerate(result):
                if index == 2:
                    result[index] = float(result[index])
            result_dict = {'Education': {'UG': result}}
            result_dict = {'Education': {'10th standard': result}}
            db.search_and_insert(email, 'candidate_features', result_dict,'double')
            data1 = unpack_response(response, data)
            return data1

        elif ('dob' in contextvariable.keys()) and ('12th' in contextvariable['cand_result']):
            result = e.split_and_compile(contextvariable['cand_result']['12th'])
            for index, val in enumerate(result):
                if index == 2:
                    result[index] = float(result[index])
            result_dict = {'Education': {'UG': result}}
            result_dict = {'Education': {'12th standard': result}}
            db.search_and_insert(email, 'candidate_features', result_dict,'double')
            data1 = unpack_response(response, data)
            return data1

        elif ('dob' in contextvariable.keys()) and ('UG' in contextvariable['cand_result']):
            result = e.split_and_compile(contextvariable['cand_result']['UG'])
            for index, val in enumerate(result):
                if index == 2:
                    result[index] = float(result[index])
            result_dict = {'Education': {'UG': result}}
            db.search_and_insert(email, 'candidate_features', result_dict,'double')
            data1 = unpack_response(response, data)
            return data1

        elif ('dob' in contextvariable.keys()) and ('Skill' in contextvariable['cand_result']):

            ##ensure lowercase for skills
            result = e.split_and_compile(contextvariable['cand_result']['Skill'])
            result = [i.lower() for i in result]
            result_dict = {'Skill': result}
            db.search_and_insert(email, 'candidate_features', result_dict, flag= 'single')
            data1 = unpack_response(response, data)
            return data1

        elif ('dob' in contextvariable.keys()) and ('Hobbies' in contextvariable['cand_result']):
            result = e.split_and_compile(contextvariable['cand_result']['Hobbies'])
            result_dict = {'Hobbies': result}
            db.search_and_insert(email, 'candidate_features', result_dict, flag= 'single')
            data1 = unpack_response(response,data)
            return data1

        elif ('dob' in contextvariable.keys()) and ('Project' in contextvariable['cand_result']):
            if not contextvariable['cand_result']['Project']:
                data1 = unpack_response(response, data)
                return data1
            else:
                result = e.split_and_compile(contextvariable['cand_result']['Project'])
                result_dict = {'Project': {
                    result[0]: [result[1], result[2]]
                }}
                db.search_and_insert(email, 'candidate_features', result_dict, flag = 'double')
                data1 = unpack_response(response, data)
                return data1

        elif ('dob' in contextvariable.keys()) and ('Internship' in contextvariable['cand_result']):
            if not contextvariable['cand_result']['Internship']:
                data1 = unpack_response(response, data)
                return data1
            else:
                result = e.split_and_compile(contextvariable['cand_result']['Internship'])
                result_dict = {'Internship': {
                    result[0]: [result[1], result[2]]
                }}
                db.search_and_insert(email, 'candidate_features', result_dict, flag = 'double')
                data1 = unpack_response(response, data)
                return data1

        elif ('dob' in contextvariable.keys()) and ('Achievement' in contextvariable['cand_result']):
            rek = {}
            if not contextvariable['cand_result']['Achievement']:
                my_document = db.search_feature(email, 'candidate_features')
                if my_document['Education'][2]['UG'][2] >= 7.0:
                    rek['first_round_flag'] = 'Pass'
                    rek['test_link_share'] = "http://127.0.0.1:5000/test"
                    db.search_and_insert(email, 'candidate_features', rek, flag ='single')
                else:
                    my_document['first_round_flag'] = 'Fail'
                    rek = contextvariable['cand_result']['Achievement']
                    db.search_and_insert(email, 'candidate_features', rek, flag ='single')
                data1 = unpack_response(response, data)
                return data1
            else:
                result_dict = {'Achievement': contextvariable['cand_result']['Achievement']}
                db.search_and_insert(email, 'candidate_features', result_dict, flag ='double')
                data1 = unpack_response(response, data)
                return data1
        else:
            data1 = unpack_response(response, data)
            return data1
Example #10
0
from flask import redirect, render_template, session, request, make_response
from app.dbservices import crud
from app import app
from app.machine_learning.watson import watsonhandler
from werkzeug.security import generate_password_hash, check_password_hash
from flask_socketio import SocketIO, join_room
from app.handler import convo_handler
from app.machine_learning.data_extractor import extractor
from app.test_relate import generate_test as gt
from app.candidate_scoring import scoring as sc
from app.machine_learning import pers as pp
import json
import pdfkit

db = crud()
cand = {}
hand = convo_handler()
wh = watsonhandler()
socketio = SocketIO(app)


@app.route('/')
@app.route('/index', methods=['POST', 'GET'])
def index():
    return render_template('index.html')


@app.route('/login', methods=['POST', 'GET'])
def login():
    if request.method == 'POST':
        email = request.form['email']
Example #11
0
def gettest(username):
    db = crud()
    doc = []
    docfinal = []
    skillss = []
    dicto = {}
    skill = ["c", "cpp", "c++", "java", "python"]
    dicto = db.search_feature(username, 'candidate_features')

    skills = dicto["Skill"]
    for i in skills:
        if i in skill:
            skillss.append(i)
    length = len(skillss)

    if length == 4:
        doc = gettestdata("C", 'test_question', 5)
        doc1 = gettestdata("CPP", 'test_question', 5)
        doc2 = gettestdata("Java", 'test_question', 5)
        doc3 = gettestdata("python", 'test_question', 5)
        docfinal = doc + doc1 + doc2 + doc3
        return (docfinal)
    elif length == 3:
        j = 0
        for i in skillss:
            if j == 12:
                if i == "c":
                    doc = gettestdata("C", 'test_question', 8)
                elif i == "cpp" or i == "c++":
                    doc = gettestdata("CPP", 'test_question', 8)
                elif i == "java":
                    doc = gettestdata("Java", 'test_question', 8)
                elif i == "python":
                    doc = gettestdata("python", 'test_question', 8)
            else:
                if i == "c":
                    doc = gettestdata("C", 'test_question', 6)
                elif i == "cpp" or i == "c++":
                    doc = gettestdata("CPP", 'test_question', 6)
                elif i == "java":
                    doc = gettestdata("Java", 'test_question', 6)
                elif i == "python":
                    doc = gettestdata("python", 'test_question', 6)
            j = j + 6
            docfinal += doc
        return (docfinal)
    elif length == 2:
        for i in skillss:
            if i == "c":
                doc = gettestdata("C", 'test_question', 10)
            elif i == "cpp" or i == "c++":
                doc = gettestdata("CPP", 'test_question', 10)
            elif i == "java":
                doc = gettestdata("Java", 'test_question', 10)
            elif i == "python":
                doc = gettestdata("python", 'test_question', 10)
            docfinal += doc
        return (docfinal)
    else:
        doc = gettestdata(skillss[0], 'test_question', 20)
        return doc