From 2f58e8796c005b238d1c34157822cc6a998becca Mon Sep 17 00:00:00 2001 From: D VAMSIDHAR Date: Tue, 12 Mar 2024 19:04:03 +0530 Subject: [PATCH] Data Interaction Application --- .../Employee Details.json | 58 +++++ .../Intent Recognition.py | 209 ++++++++++++++++++ User-Query-Portal-Superstore/Jobs.xlsx | Bin 0 -> 13443 bytes User-Query-Portal-Superstore/README.md | 5 + .../User_Query_Application.py | 130 +++++++++++ User-Query-Portal-Superstore/requirements.txt | 7 + 6 files changed, 409 insertions(+) create mode 100644 User-Query-Portal-Superstore/Employee Details.json create mode 100644 User-Query-Portal-Superstore/Intent Recognition.py create mode 100644 User-Query-Portal-Superstore/Jobs.xlsx create mode 100644 User-Query-Portal-Superstore/README.md create mode 100644 User-Query-Portal-Superstore/User_Query_Application.py create mode 100644 User-Query-Portal-Superstore/requirements.txt diff --git a/User-Query-Portal-Superstore/Employee Details.json b/User-Query-Portal-Superstore/Employee Details.json new file mode 100644 index 0000000..b22bb63 --- /dev/null +++ b/User-Query-Portal-Superstore/Employee Details.json @@ -0,0 +1,58 @@ +[ + { + "Name ":"Mr. Dinesh Sahu", + "Department ":"Sales Department", + "Support ":"Shipping and Delivery", + "Phone Number ":9685743214, + "Email Id ": "dineshsahu3456@gmail.com" + }, + { + "Name ":"Mrs. Nandini Anand", + "Department ":"Sales Department", + "Support ":"General Assistance", + "Phone Number ":9685743232, + "Email Id ": "anandnandini3456@gmail.com" + }, + { + "Name ":"Mr. Shaurya Shrivastava", + "Department ":"Technical Department", + "Support ":"Service Inquiry", + "Phone Number ":9685743233, + "Email Id ": "shauryas2002@gmail.com" + }, + { + "Name ":"Mr. Sandeep Singh", + "Department ":"Technical Department", + "Support ":"Technical Support", + "Phone Number ":9685743210, + "Email Id ": "sandeepsingh1234@gmail.com" + }, + { + "Name ":"Mr. Raghunandan Verma", + "Department ":"Customer Service", + "Support ":"Information Request", + "Phone Number ":9685743250, + "Email Id ": "raghunandanv3456@gmail.com" + }, + { + "Name ":"Mr. Jayawardhan Rajagopal", + "Department ":"Customer Service", + "Support ":"Information Request", + "Phone Number ":9685743299, + "Email Id ": "jayawardhanrajgopal3456@gmail.com" + }, + { + "Name ":"Mr. Sriman Narayana", + "Department ":"Sales Department", + "Support ":"Product Inquiry", + "Phone Number ":9685743299, + "Email Id ": "srimannarayana@gmail.com" + }, + { + "Name ":"Mr. Jayaraj", + "Department ":"Technical Department", + "Support ":"Account Assistance", + "Phone Number ":9685743298, + "Email Id ": "jayaraj3490@gmail.com" + } +] \ No newline at end of file diff --git a/User-Query-Portal-Superstore/Intent Recognition.py b/User-Query-Portal-Superstore/Intent Recognition.py new file mode 100644 index 0000000..de67c76 --- /dev/null +++ b/User-Query-Portal-Superstore/Intent Recognition.py @@ -0,0 +1,209 @@ +#!/usr/bin/env python +# coding: utf-8 + +# In[1]: + + +import pandas as pd +import difflib +from sklearn.feature_extraction.text import TfidfVectorizer +from sklearn.metrics.pairwise import cosine_similarity +from nltk.tokenize import RegexpTokenizer + + +# In[2]: + + +data = pd.read_excel('Jobs.xlsx') +data.head() + + +# In[3]: + + +# removing punctuations from the query of the customer +tokenizer = RegexpTokenizer(r'\w+') +data['Query of the Customer'] = data['Query of the Customer'].apply(lambda x: ' '.join(tokenizer.tokenize(x))) + + +# In[4]: + + +# combining all the column's data into a single feature to use it for processing of the queries +combine_feat = data['Query of the Customer'] + ' ' + data['Query Type'] + ' ' + data['Who Can Help'] +combine_feat + + +# In[5]: + + +# to vectorize the features + +vectorizer = TfidfVectorizer() +feature_vectors = vectorizer.fit_transform(combine_feat) + + +# In[6]: + + +# similarity scores +similarity = cosine_similarity(feature_vectors) + + +# In[7]: + + +print(similarity) + + +# In[8]: + + +# taking user input as query +query = input('Enter your query : ') + + +# In[9]: + + +# putting all the queries into one list +list_of_all_queries =data['Query of the Customer'].tolist() +list_of_all_queries + + +# In[10]: + + +# finding closest match to user input from the list of all queries + +find_close_match = difflib.get_close_matches(query, list_of_all_queries) +find_close_match + + +# In[11]: + + +close_match = find_close_match[0] +close_match + + +# In[12]: + + +#index of the closest match +index_of_the_query = data[data['Query of the Customer'] == close_match]['index'].values[0] +index_of_the_query + + +# In[13]: + + +# checking similarity with every query in the dataset + +similarity_score = list(enumerate(similarity[index_of_the_query])) +similarity_score + + +# In[14]: + + +len(similarity_score) + + +# In[15]: + + +#sorting the similarity score list +sorted_similarity_score = sorted(similarity_score, key = lambda x:x[1], reverse = True) +print(sorted_similarity_score) + + +# In[16]: + + +print('Your query is related to : \n') + +i = 1 + +query_of_the_user = list() + +for query1 in sorted_similarity_score: + index = query1[0] + query_of_the_user.append(data[data.index==index]['Query Type'].values[0]) + +print(query_of_the_user) + +# for name in query_type: +# print(name) + + +# In[17]: + + +print('Your query is related to : ') +# Set to store unique elements encountered so far +query_type = set() +i = 0 +# Iterate over the list and print only those elements that are not in the set +for word in query_of_the_user: + if word not in query_type: + print(word) + query_type.add(word) + i+=1 + + if i>=3: + break + + +# ### Fetching the details from json file to help the user contact the necessary support + +# In[18]: + + +import json + +def find_details(query_1): + + # Load the JSON data from the file + with open("Employee Details.json", "r") as f: + data = json.load(f) + + # Find employees with matching support + matching_details = [] + for details in data: + if query_1.lower() in details["Support "].lower(): + matching_details.append(details) + + return matching_details + + +# In[20]: + + +query_1 = query_of_the_user[0] +matching_details = find_details(query_1) + +print("USER's Query : ") +print(query) +print("Query related to : ",query_of_the_user[0]) +print("="*50) +print("Please contanct the following person for help : ") +print("="*50) +if matching_details: + # Print employee information + for employee in matching_details: + print(f"Employee Name: {employee['Name ']}") + print(f"Department: {employee['Department ']}") + print(f"Support: {employee['Support ']}") + print(f"Phone Number: {employee['Phone Number ']}") + print(f"Email: {employee['Email Id ']}") + print("-" * 20) +else: + print("No matching employees found.") + + +# In[ ]: + + + + diff --git a/User-Query-Portal-Superstore/Jobs.xlsx b/User-Query-Portal-Superstore/Jobs.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..7df690e5d457a2ce0d95259e35398134223c1637 GIT binary patch literal 13443 zcmeIZ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WA#7NCTF3rmqN zQfd6`@ooEUTUgcg#)OK4Yq(?v;Y`|4L)w6=T#c^(Gjc2yWv6PGqK3G=UmSj%?%RZBQi1DtlM^%9s zsUnZ?{=&gk7O{M`DWR<{=sxMOsE*6Xy7=C^dLuDCJnXR1K)*IGk0CL=$uT0 z&kd4d9r}o9q`E%R0k`4EV)k>v7X+Y>n~i$zy$vdKy7Ubt&zq1M=;fJ+1_en?f!^l` zdO%K`^_L)HuDda-J26HH2<-hnQUh?qO#+Ag0f-k%4$5hso?))b0j5iN&SgJ4Zl|&L zdMOHzR33z1O}@tlD&KYont4iob+dxin|J3|S)MZ~et?oc=0}?0vtxN8HCauq4t|`y z?quS9*}mz%z54XQo8dv%jFn>jrS=8kKaLd)oE{Vz`sY7V{AarUbN+|FRVd2*Rl#3N zy#FKk>s$n~iT^72{$23*ve!RFM?i_k--=*=7yfIV;Gd!ZzygR^{r^`D{;ucu;;}z9 zAt3&L5AnBBvfs7*o-O@Tivi|8=1zZC@O!BGPX*)ze<=7faQ(aJ?*YF*MR7qnWza}C z{T}}NUBmCR`%ewCAP)N1a=L#c;lC^VoyGpCaQ@vN3V-9U|Hx^7SNc~D@TW=u;EWak p_!}emUHq?(`oG0P82(HA-)>t`1`32h000s6q6EQMg8A3C{|6Ah5b^*3 literal 0 HcmV?d00001 diff --git a/User-Query-Portal-Superstore/README.md b/User-Query-Portal-Superstore/README.md new file mode 100644 index 0000000..3c64859 --- /dev/null +++ b/User-Query-Portal-Superstore/README.md @@ -0,0 +1,5 @@ +Python application that simulates interaction with a database, processes user queries, and +returns relevant data. + +#### Link to the web app : +https://user-query-app-superstore-y8vraqdk2rbuepindrdkv8.streamlit.app/ diff --git a/User-Query-Portal-Superstore/User_Query_Application.py b/User-Query-Portal-Superstore/User_Query_Application.py new file mode 100644 index 0000000..d8c7ac7 --- /dev/null +++ b/User-Query-Portal-Superstore/User_Query_Application.py @@ -0,0 +1,130 @@ +# -*- coding: utf-8 -*- +""" +Created on Thu Feb 29 22:38:35 2024 + +@author: D VAMIDHAR (dvamsidhar2002@gmail.com) +""" + +# Importing necessary libraries + + +import pandas as pd +import difflib +from sklearn.feature_extraction.text import TfidfVectorizer +from sklearn.metrics.pairwise import cosine_similarity +from nltk.tokenize import RegexpTokenizer +import streamlit as st + +def intent_recognition(query): + data = pd.read_excel('Jobs.xlsx') + + tokenizer = RegexpTokenizer(r'\w+') + data['Query of the Customer'] = data['Query of the Customer'].apply(lambda x: ' '.join(tokenizer.tokenize(x))) + + combine_feat = data['Query of the Customer'] + ' ' + data['Query Type'] + ' ' + data['Who Can Help'] + + # to vectorize the features + + vectorizer = TfidfVectorizer() + feature_vectors = vectorizer.fit_transform(combine_feat) + + # similarity scores + similarity = cosine_similarity(feature_vectors) + + + + list_of_all_queries =data['Query of the Customer'].tolist() + find_close_match = list() + find_close_match = difflib.get_close_matches(query, list_of_all_queries) + + close_match = find_close_match[0] + + index_of_the_query = data[data['Query of the Customer'] == close_match]['index'].values[0] + + similarity_score = list(enumerate(similarity[index_of_the_query])) + + sorted_similarity_score = sorted(similarity_score, key = lambda x:x[1], reverse = True) + + query_of_the_user = list() + + for query1 in sorted_similarity_score: + index = query1[0] + query_of_the_user.append(data[data.index==index]['Query Type'].values[0]) + + + print('Your query is related to : ') + # Set to store unique elements encountered so far + query_type = set() + i = 0 + # Iterate over the list and print only those elements that are not in the set + for word in query_of_the_user: + if word not in query_type: + print(word) + query_type.add(word) + i+=1 + + if i>=3: + break + + import json + + def find_details(query_1): + + # Load the JSON data from the file + with open("Employee Details.json", "r") as f: + data = json.load(f) + + # Find employees with matching support + matching_details = [] + for details in data: + if query_1.lower() in details["Support "].lower(): + matching_details.append(details) + + return matching_details + + query_1 = query_of_the_user[0] + matching_details = find_details(query_1) + + def format_employee_info(employee): + info_string = (f"Query related to : {query_type}\n\n" + f"\nPLEASE CONTACT THE FOLLOWING PERSON FOR SOLUTION : \n" + f"\nEmployee Name: {employee['Name ']}\n" + f"\nDepartment: {employee['Department ']}\n" + f"\nSupport: {employee['Support ']}\n" + f"\nPhone Number: {employee['Phone Number ']}\n" + f"\nEmail: {employee['Email Id ']}\n" + + "-" * 20 + "\n") + return info_string + + query_1 = query_of_the_user[0] + matching_details = find_details(query_1) + + print("USER's Query : ") + print(query) + print("Query related to : ", query_of_the_user[0]) + print("="*50) + print("Please contact the following person(s) for help : ") + print("="*50) + if matching_details: + # Print employee information + for employee in matching_details: + employee_info_string = format_employee_info(employee) + return employee_info_string + else: + return "No matching employees found." + + +def main(): + st.title('User Interaction Portal') + #user input + query = st.text_input('Enter your query : ') + + if st.button('Post Query'): + response = intent_recognition(query) + + st.success(response) + + +if __name__ == "__main__": + main() + diff --git a/User-Query-Portal-Superstore/requirements.txt b/User-Query-Portal-Superstore/requirements.txt new file mode 100644 index 0000000..33f85f6 --- /dev/null +++ b/User-Query-Portal-Superstore/requirements.txt @@ -0,0 +1,7 @@ +numpy +pickle-mixin +streamlit +scikit-learn +nltk +pandas +openpyxl