import re
from collections import Counter
from user_functions import preprocess, compare_overlap, pos_tag, extract_nouns, compute_similarity
import spacy

word2vec = spacy.load('en')

exit_commands = ("quit", "goodbye", "exit", "no")

response_a = "Available vacancies for assistant developer are 100 for now."
response_b = "Location of job is work from home."
response_c = "We will mail you once you get selected."

responses = [response_a, response_b, response_c]

class ChatBot:
    def make_exit(self, user_message):
        for exit_command in exit_commands:
            if exit_command in user_message:
             print("Ok, bye!")
            return True 
    def chat(self):
        welcome_msg = print("Welcome to Recons Recruitment Assistane!\nI am here to interview you. Your answers will decide your rank among all candidates and then you will be called for walk-in-interview. Best wishes! ")
        name= input("May I have your name please? ")
        q1 = print("Great! " + str(name) + "! Now, I will ask you some questions to test your personality and aptitude. ")
        q2 = input("Amazing, " + str(name) + "! Now, I would like ask you about your weaknesses? ")
        q3 = input("Hope you improve it. Let's talk about strengths. ")
        user_message = input("Do you have any questions for me? ")
        while not self.make_exit(user_message):
            user_message = self.respond(user_message)
    def find_intent_match(self, responses, user_message):
        bow_user_message = Counter(preprocess(user_message))
        processed_responses = [Counter(preprocess(response)) for response in responses]
        similarity_list = [compare_overlap(doc, bow_user_message) for doc in processed_responses]
        response_index = similarity_list.index(max(similarity_list))
        return responses[response_index]
    def respond(self, user_message):
        best_response = self.find_intent_match(responses, user_message)
        q = input("Do you have any other questions?\nyes/no")
        input_message = input("Do you have any other questions? ")           
        return input_message
    def email(self):
        emailid = input("Share your Email-ID")
        return print("You will receive an email for walk-in-interview, incase you get selected. On-" + str(emailid) + "\nThank you!")

recons_assistance = ChatBot()

import re
from collections import Counter
import spacy
word2vec = spacy.load('en')
from nltk import pos_tag
from nltk.tokenize import word_tokenize
from nltk.corpus import stopwords
stop_words = set(stopwords.words("english"))

def preprocess(input_sentence):
    input_sentence = input_sentence.lower()
    input_sentence = re.sub(r'[^\w\s]','',input_sentence)
    tokens = word_tokenize(input_sentence)
    input_sentence = [i for i in tokens if not i in stop_words]

def compare_overlap(user_message, possible_response):
    similar_words = 0
    for token in user_message:
        if token in possible_response:
              similar_words += 1
    return similar_words
def extract_nouns(tagged_message):
    message_nouns = list()
    for token in tagged_message:
        if token[1].startswith("N"):
    return message_nouns

def compute_similarity(tokens, category):
    output_list = list()
    for token in tokens:
        output_list.append([token.text, category.text, token.similarity(category)])
    return output_list

please tell me error that i am getting

It might help if you provided details on the full error code you’re receiving, with line number etc.

If you’re not receiving an error then the difference between the output you expected and the output you are getting along with your interpretation of what you think is happening would be helpful.

1 Like