Spaces:
Sleeping
Sleeping
Update README.md
Browse files
README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
---
|
2 |
-
title: '
|
3 |
emoji: π
|
4 |
colorFrom: gray
|
5 |
colorTo: pink
|
@@ -8,3 +8,139 @@ pinned: false
|
|
8 |
---
|
9 |
|
10 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
title: 'Multilingual Sentiment Analyzer'
|
3 |
emoji: π
|
4 |
colorFrom: gray
|
5 |
colorTo: pink
|
|
|
8 |
---
|
9 |
|
10 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
11 |
+
π Multilingual Sentiment Analyzer
|
12 |
+
A comprehensive AI-powered sentiment analysis application with explainable AI features (SHAP & LIME) supporting multiple languages.
|
13 |
+
π Features
|
14 |
+
|
15 |
+
Multi-language Support: Auto-detect or manually select from English, Chinese, Spanish, French, German, Swedish
|
16 |
+
Advanced Analysis: SHAP and LIME explainable AI integration
|
17 |
+
Batch Processing: Analyze multiple texts simultaneously with parallel processing
|
18 |
+
Interactive Visualizations: Real-time charts and dashboards with Plotly
|
19 |
+
History Management: Track and export analysis history
|
20 |
+
Multiple Themes: Customizable color themes for visualizations
|
21 |
+
File Upload: Support for CSV and TXT file uploads
|
22 |
+
Export Functionality: Export results in CSV and JSON formats
|
23 |
+
|
24 |
+
π Project Structure
|
25 |
+
sentiment_analyzer/
|
26 |
+
βββ config.py # Configuration settings
|
27 |
+
βββ models.py # Model management & sentiment engine
|
28 |
+
βββ analysis.py # SHAP/LIME explainable AI
|
29 |
+
βββ visualization.py # Plotly visualizations
|
30 |
+
βββ data_utils.py # Data processing & history management
|
31 |
+
βββ app.py # Application logic
|
32 |
+
βββ main.py # Gradio interface & startup
|
33 |
+
βββ requirements.txt # Python dependencies
|
34 |
+
βββ Dockerfile # Docker configuration
|
35 |
+
βββ README.md # This file
|
36 |
+
π Installation
|
37 |
+
Option 1: Local Installation
|
38 |
+
bash# Clone the repository
|
39 |
+
git clone <repository-url>
|
40 |
+
cd sentiment_analyzer
|
41 |
+
|
42 |
+
# Install dependencies
|
43 |
+
pip install -r requirements.txt
|
44 |
+
|
45 |
+
# Download NLTK data
|
46 |
+
python -c "import nltk; nltk.download('stopwords'); nltk.download('punkt')"
|
47 |
+
|
48 |
+
# Run the application
|
49 |
+
python main.py
|
50 |
+
Option 2: Docker
|
51 |
+
bash# Build the Docker image
|
52 |
+
docker build -t sentiment-analyzer .
|
53 |
+
|
54 |
+
# Run the container
|
55 |
+
docker run -p 7860:7860 sentiment-analyzer
|
56 |
+
Option 3: Hugging Face Spaces
|
57 |
+
|
58 |
+
Create a new Space on Hugging Face
|
59 |
+
Select "Docker" as the SDK
|
60 |
+
Upload all project files
|
61 |
+
The app will automatically deploy
|
62 |
+
|
63 |
+
π― Usage
|
64 |
+
Single Text Analysis
|
65 |
+
|
66 |
+
Navigate to the "Single Analysis" tab
|
67 |
+
Enter your text in any supported language
|
68 |
+
Select language (or use Auto Detect)
|
69 |
+
Choose visualization theme
|
70 |
+
Configure preprocessing options
|
71 |
+
Click "Analyze"
|
72 |
+
|
73 |
+
Advanced Analysis (SHAP/LIME)
|
74 |
+
|
75 |
+
Go to "Advanced Analysis" tab
|
76 |
+
Enter text for explainable AI analysis
|
77 |
+
Adjust number of samples (50-300)
|
78 |
+
Click "SHAP Analysis" or "LIME Analysis"
|
79 |
+
View feature importance visualizations
|
80 |
+
|
81 |
+
Batch Processing
|
82 |
+
|
83 |
+
Switch to "Batch Analysis" tab
|
84 |
+
Upload a file or enter multiple texts (one per line)
|
85 |
+
Configure analysis settings
|
86 |
+
Click "Analyze Batch"
|
87 |
+
View summary statistics and detailed results
|
88 |
+
|
89 |
+
History & Analytics
|
90 |
+
|
91 |
+
Open "History & Analytics" tab
|
92 |
+
View comprehensive analysis dashboard
|
93 |
+
Export data in CSV or JSON format
|
94 |
+
Clear history when needed
|
95 |
+
|
96 |
+
π§ Configuration
|
97 |
+
Edit config.py to customize:
|
98 |
+
|
99 |
+
Model Settings: Change supported models and languages
|
100 |
+
Processing Limits: Adjust batch sizes and memory limits
|
101 |
+
UI Themes: Modify color schemes
|
102 |
+
Cache Settings: Configure caching parameters
|
103 |
+
|
104 |
+
π Supported Models
|
105 |
+
|
106 |
+
English: CardiffNLP Twitter RoBERTa
|
107 |
+
Multilingual: CardiffNLP XLM-RoBERTa
|
108 |
+
Chinese: UER RoBERTa Chinese
|
109 |
+
|
110 |
+
π¨ Themes
|
111 |
+
|
112 |
+
Default: Green/Red/Orange
|
113 |
+
Ocean: Blue/Orange/Cyan
|
114 |
+
Dark: Darker variants
|
115 |
+
Rainbow: Purple/Pink/Red
|
116 |
+
|
117 |
+
β‘ Performance Features
|
118 |
+
|
119 |
+
Model Caching: LRU cache for efficient model management
|
120 |
+
Parallel Processing: Multi-threaded batch analysis
|
121 |
+
Memory Optimization: Automatic cleanup and GPU management
|
122 |
+
Lazy Loading: Models loaded on-demand
|
123 |
+
|
124 |
+
π Troubleshooting
|
125 |
+
Common Issues
|
126 |
+
|
127 |
+
SHAP/LIME Errors: Reduce sample size or text length
|
128 |
+
Memory Issues: Lower batch size or enable text cleaning
|
129 |
+
Model Loading: Check internet connection for model downloads
|
130 |
+
Port Conflicts: Change port in main.py if 7860 is occupied
|
131 |
+
|
132 |
+
Performance Tips
|
133 |
+
|
134 |
+
Use GPU if available for faster processing
|
135 |
+
Enable text cleaning for better preprocessing
|
136 |
+
Reduce sample sizes for faster explainable AI analysis
|
137 |
+
Clear history periodically to save memory
|
138 |
+
|
139 |
+
π License
|
140 |
+
This project is open source and available under the MIT License.
|
141 |
+
π€ Contributing
|
142 |
+
Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.
|
143 |
+
π Support
|
144 |
+
For support and questions, please open an issue in the repository.
|
145 |
+
|
146 |
+
Built with β€οΈ using Gradio, Transformers, SHAP, LIME, and Plotly
|