File size: 3,266 Bytes
b3f8933
24a02b6
df28b21
b3f8933
 
 
 
8ce8cfa
b3f8933
 
24a02b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b3f8933
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
---
title: Manifesto Explainer with LLM Enhancement
emoji: πŸ“ˆ
colorFrom: blue
colorTo: red
sdk: gradio
app_file: app.py
pinned: true
---

# Manifesto Explainer with LLM Enhancement

This application analyzes political manifestos using advanced NLP and LLM techniques. It provides various insights including word frequency analysis, sentiment analysis, word clouds, and AI-generated summaries.

## Features

- **AI-Generated Summary**: Uses Groq's LLaMA 3 model to generate concise summaries of manifestos
- **Enhanced Relevant Words Analysis**: Combines traditional frequency analysis with TF-IDF to find the most relevant topics
- **Context-Based Search**: Find specific terms within the manifesto with surrounding context
- **Visualizations**:
  - Word Cloud: Visual representation of the most frequent words
  - Sentiment Analysis: Analysis of positive, negative, and neutral sentiments
  - Subjectivity Analysis: Analysis of subjective vs. objective content
  - Frequency Distribution: Distribution of word frequencies
  - Dispersion Plot: Visual representation of word occurrences throughout the text

## Setup

1. Install the required dependencies:
   ```
   pip install -r requirements.txt
   ```

2. Set up your Groq API key:
   - Rename the `.env.example` file to `.env`
   - Add your Groq API key to the `.env` file:
     ```
     GROQ_API_KEY=your_groq_api_key_here
     ```
   - You can get a Groq API key by signing up at [https://console.groq.com/](https://console.groq.com/)

3. Run the application:
   ```
   python app.py
   ```

4. Open the application in your web browser at the URL displayed in the terminal (typically http://127.0.0.1:7860)

## Usage

1. Upload a PDF file containing a political manifesto
2. Enter a search term to find specific mentions in the manifesto
3. Click "Analyze Manifesto" to process the document
4. View the results in the different tabs:
   - **Summary**: AI-generated summary of the manifesto
   - **Search Results**: Occurrences of your search term with context
   - **Key Topics**: Most relevant topics identified using LLM-enhanced analysis
   - **Visualizations**: Various visualizations of the manifesto content

## Example Manifestos

The application comes with example manifestos in the `Example` folder:
- AAP Manifesto 2019
- BJP Manifesto 2019
- Congress Manifesto 2019

## Note

If the Groq API key is not set up correctly, the summarization feature will be disabled, but all other features will continue to work.

## Configuration

`title`: _string_  
Display title for the Space

`emoji`: _string_  
Space emoji (emoji-only character allowed)

`colorFrom`: _string_  
Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)

`colorTo`: _string_  
Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)

`sdk`: _string_  
Can be either `gradio` or `streamlit`

`sdk_version` : _string_  
Only applicable for `streamlit` SDK.  
See [doc](https://hf.co/docs/hub/spaces) for more info on supported versions.

`app_file`: _string_  
Path to your main application file (which contains either `gradio` or `streamlit` Python code).  
Path is relative to the root of the repository.

`pinned`: _boolean_  
Whether the Space stays on top of your list.