A module for analyzing presidential speeches
Project description
PyChatBot Presidential Speech Analysis EFREI
Overview
This Python script analyzes the speeches of various presidents. It performs pre-processing on the speech texts and provides basic functions for text analysis, including the calculation of TF-IDF (Term Frequency-Inverse Document Frequency) matrices.
Project Structure
The project is structured as follows:
- app.py : The main application file.
- Basic_Functions.py : Contains basic functions used in the application.
- Cosine_Similarity_Functions.py : Contains functions for calculating cosine similarity.
- Features_to_be_Developed.py: Contains functions for features to be developed.
- Menu.py: Contains the application menu.
- Pre_Processing.py : Contains functions for data pre-processing.
- tokenization_question.py : Contains functions for tokenizing questions.
- cleaned/ : Contains cleaned presidential speeches.
- speeches/ : Contains original presidential speeches.
- static/ and templates/: Contain files for the application's user interface.
Pre-Processing
- Extract President Names: Extracts the names of the presidents from the filenames of speech texts.
- Associate First Name: Associates a first name with each president.
- Display President Names: Displays the list of president's names, avoiding duplicates.
- Text Conversion: Converts the original speech texts to lowercase and creates cleaned versions in the "cleaned" folder.
- Remove Punctuation: Removes punctuation characters from the cleaned speech texts.
Basic Functions
- Proportion in Documents: Calculates the proportion of documents containing a given word.
- Get Unique Words: Retrieves a list of unique words from the cleaned texts.
- Get TF Matrix: Generates a Term Frequency (TF) matrix for the words in the speeches.
- Get IDF Scores: Calculates the Inverse Document Frequency (IDF) scores for the unique words.
- Get TF-IDF Matrix: Calculates the TF-IDF matrix using the TF matrix and IDF scores.
- Transpose Matrix: Transposes a given matrix.
Features
1. Display Least Important Words
- Function:
get_least_important_words(directory) - Description: Retrieves words with TF-IDF score equal to 0.
2. Display Highest TF-IDF Score
- Function:
display_highest_tfidf_score(directory) - Description: Identifies words with the highest TF-IDF scores.
3. Most Repeated Words
- Function:
most_repeated_words(directory) - Description: Identifies the most repeated words in the speeches.
4. First President to Talk About a Word
- Function:
first_president_word(word) - Description: Identifies the first president to mention a specific word.
5. President who said the most a word
- Function:
president_who_said_it_the_most(word,directory) - Description: Identifies the president who said a word the most.
6. Get president names
- Function:
extract_presidents_names(directory) - Description: Display the names of the presidents.
Usage
- Clone this repository.
- Install dependencies with
pip install <name of the dependency>. - Run
python app.pyorflask runto start the application. - Open your browser at
http://localhost:5000to use the application.
Menu
- The script includes a menu-driven interface for user interaction. Users can choose specific tasks from the menu.
Dependencies
- Python 3.x >= 3.9
- Flask
- Random
- Math
- OS
- Re
Authors
Andrea CHARVIERE and Antonin LARTILLOT-AUTEUIL
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file PyLogicBot-0.1.tar.gz.
File metadata
- Download URL: PyLogicBot-0.1.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cab3ce62fcc8da00222c0fa40b3f3790cc57f9ed6a1a2363ad5c0d33f723f95a
|
|
| MD5 |
d1ad7fd5884a15b975c0a30efcf07e9e
|
|
| BLAKE2b-256 |
22f4aeb1253e5ea5d4464412eeffe005aeb522a7e444b4397fc6bd472302e778
|
File details
Details for the file PyLogicBot-0.1-py3-none-any.whl.
File metadata
- Download URL: PyLogicBot-0.1-py3-none-any.whl
- Upload date:
- Size: 2.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
216acaad25177b75454d0a69f462daa02d5fe00020e3d766ca4ab19f0645ad6b
|
|
| MD5 |
25506817dd3597339c6ed46de85a8913
|
|
| BLAKE2b-256 |
a572fb21b029d4ba508898a90897b2d30d9ca88148f3cd36fcf6dc0f56e28233
|