CoxJames - Feedback Categorisation and Sentiment Analysis
The project consists of two Python codes: CoxJames_CategoryAnalysis.py
and CoxJames_FeedbackCategorisation+SentimentAnalysis.py
. These codes are designed to perform category analysis and sentiment analysis on feedback data stored in Excel files.
By combining these two codes, users can analyse feedback data, extract relevant keywords, categorise feedback, and perform sentiment analysis, allowing them to gain valuable insights into the feedback received and understand the sentiment associated with different categories. These insights can be utilised for various purposes, such as improving products or services, identifying areas of improvement, and making data-driven decisions based on customer feedback.
The main purpose of CoxJames_CategoryAnalysis.py
is to analyse feedback data and extract relevant keywords for predefined category. The code reads an Excel file containing feedback and category information. It tokenises the feedback, removes stopwords, creates n-grams, and tags the tokens with part-of-speech tags. It then extracts keywords based on the assigned categories and writes them to the "Dictionary" sheet of another Excel file. This code helps in identifying significant keywords associated with each feedback category.
-
Install the required libraries:
pip install openpyxl nltk
-
Place the Python script (
CoxJames_CategoryAnalysis.py
) in a directory along with the following files:- The input Excel file containing feedback and categories.
- The
Stopwords List Expanded.txt
file.
-
Open the Python script in a text editor.
-
Replace
'INSERT EXCEL FILE NAME'
with the actual filename of the input Excel file. The line to modify is:wb = openpyxl.load_workbook(os.path.join(dir_path, 'INSERT EXCEL FILE NAME'))
-
Save the changes to the Python script.
-
Open a terminal or command prompt and navigate to the directory where the Python script is located.
-
Run the Python script:
python CoxJames_CategoryAnalysis.py
The script will execute and perform the category analysis on the feedback data.
-
After the execution completes, a new Excel file named
Dictionary_Output.xlsx
will be generated in the same directory. This file will contain the extracted keywords categorized by the original feedback categories. -
You can open the
Dictionary_Output.xlsx
file in a spreadsheet application (e.g., Microsoft Excel, Google Sheets) to view and analyze the extracted keywords. -
The category analysis process is complete. You can use the extracted keywords for further analysis or any other relevant tasks.
Note: Make sure you have appropriate permissions to read and write files in the specified directory.
The main purpose of CoxJames_FeedbackCategorisation+SentimentAnalysis.py
is to categorise feedback based on custom categories and perform sentiment analysis. It reads an Excel file containing feedback data and utilises the previously generated "Dictionary" sheet to categorise the feedback based on the extracted keywords. Additionally, the code performs sentiment analysis using the SentimentIntensityAnalyzer from the NLTK library. The results, including the assigned categories and sentiment scores, are saved in separate sheets of a new Excel file. This code enables the categorisation and sentiment analysis of feedback data, providing valuable insights into customer sentiment and feedback trends.
-
Install the required libraries:
pip install openpyxl nltk matplotlib pandas numpy
-
Place the Python script (
CoxJames_FeedbackCategorisation+SentimentAnalysis.py
) in a directory along with the following files:- The input Excel file containing feedback.
- The
Dictionary_Output.xlsx
file generated by the previous Python code (CoxJames_CategoryAnalysis.py
).
-
Open the Python script in a text editor.
-
Replace
'INSERT EXCEL FILE NAME'
with the actual filename of the input Excel file. The line to modify is:df = pd.read_excel(os.path.join(dir_path, 'INSERT EXCEL FILE NAME'), sheet_name='Raw')
-
Save the changes to the Python script.
-
Open a terminal or command prompt and navigate to the directory where the Python script is located.
-
Run the Python script:
python CoxJames_FeedbackCategorisation+SentimentAnalysis.py
The script will execute and perform the feedback categorisation and sentiment analysis.
-
After the execution completes, a new Excel file named
Category_Analysis_Output.xlsx
will be generated in the same directory. This file will contain two sheets:- summary: Contains a summary of the data, including the count and mean sentiment for each category.
- raw: Contains the original feedback data with the assigned categories and sentiment scores.
-
You can open the
Category_Analysis_Output.xlsx
file in a spreadsheet application (e.g., Microsoft Excel, Google Sheets) to view and analyse the categorised feedback and sentiment analysis results. -
The feedback categorisation and sentiment analysis process is complete. You can use the output file for further analysis or any other relevant tasks.
Note: Make sure you have appropriate permissions to read and write files in the specified directory.