File size: 2,687 Bytes
2371c3d
58eae37
 
 
2371c3d
 
58eae37
2371c3d
 
58eae37
 
 
 
 
 
 
 
 
 
 
2371c3d
 
58eae37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
title: ABSA Restaurant Reviews (FastAPI)
emoji: 🍽️
colorFrom: blue
colorTo: green
sdk: docker
app_port: 7860
pinned: false
license: mit
models:
  - ronalhung/setfit-absa-restaurants-aspect
  - ronalhung/setfit-absa-restaurants-polarity
tags:
  - sentiment-analysis
  - aspect-based-sentiment-analysis
  - setfit
  - restaurant-reviews
  - nlp
  - fastapi
  - react
---

# 🍽️ Aspect-Based Sentiment Analysis for Restaurant Reviews (FastAPI + React)

This application performs **Aspect-Based Sentiment Analysis (ABSA)** on restaurant reviews using SetFit models from Hugging Face. 

**Original FastAPI + React interface** preserved with beautiful modern UI.

## Features

- 📝 **Text Input**: Enter restaurant reviews directly
- 📁 **File Upload**: Upload .txt files containing reviews  
- 🎯 **Aspect Extraction**: Automatically detect aspects (food, service, atmosphere, etc.)
- 💭 **Sentiment Analysis**: Classify sentiment for each aspect (positive, negative, neutral, conflict)
- 🎨 **Modern UI**: Beautiful React interface with TailwindCSS
-**Fast API**: High-performance backend with FastAPI

## Models Used

1. **[ronalhung/setfit-absa-restaurants-aspect](https://huggingface.co/ronalhung/setfit-absa-restaurants-aspect)** - Aspect extraction (86.1% accuracy)
2. **[ronalhung/setfit-absa-restaurants-polarity](https://huggingface.co/ronalhung/setfit-absa-restaurants-polarity)** - Sentiment classification (69.6% accuracy)

## How to Use

1. **Text Input**: Type or paste a restaurant review in the text area
2. **File Upload**: Click "Upload Text File" to load a .txt file
3. **Analyze**: Click "Analyze Text" to get results
4. **Results**: View detected aspects and their sentiments with color-coded labels

## Example

**Input:** "The food was excellent but the service was terrible."

**Output:**
- Aspect: "food" → Sentiment: positive (green)
- Aspect: "service" → Sentiment: negative (red)

## API Endpoints

- `GET /` - Web interface
- `POST /analyze` - Analyze text (JSON API)
- `GET /health` - Health check

## Technology Stack

- **Backend**: FastAPI + SetFit models
- **Frontend**: React + TailwindCSS (inline)
- **Models**: SetFit with sentence-transformers/all-MiniLM-L6-v2
- **Deployment**: Docker on Hugging Face Spaces

## Citation

```bibtex
@article{https://doi.org/10.48550/arxiv.2209.11055,
    doi = {10.48550/ARXIV.2209.11055},
    url = {https://arxiv.org/abs/2209.11055},
    author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
    title = {Efficient Few-Shot Learning Without Prompts},
    publisher = {arXiv},
    year = {2022},
}
```