Skip to content

EastTower16/NLPService

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Text Sentiment Analysis Service

A high-performance sentiment analysis service that supports both Chinese and English text analysis, built with FastAPI and PaddlePaddle.

Features

  • Real-time sentiment analysis for single texts
  • Batch processing for multiple texts
  • Automatic language detection (Chinese/English)
  • High concurrency support
  • Containerized deployment
  • RESTful API interface

Prerequisites

  • Python 3.9+
  • Docker (for containerized deployment)
  • PaddlePaddle models (Senta)

Installation

  1. Clone the repository:
git clone <repository-url>
cd NLPService
  1. Install dependencies:
pip install -r requirements.txt
  1. Download models: Place the Senta models in the models/senta directory with the following structure:
models/senta/
├── cn_model/
│   ├── model.pdmodel
│   └── model.pdiparams
└── en_model/
    ├── model.pdmodel
    └── model.pdiparams

Running the Service

Local Development

uvicorn main:app --reload

Docker Deployment

docker build -t sentiment-service .
docker run -p 8000:8000 sentiment-service

API Usage

Single Text Analysis

curl -X POST "http://localhost:8000/analyze" \
     -H "Content-Type: application/json" \
     -d '{"text": "我很喜欢这个产品"}'

Response:

{
    "label": "positive",
    "confidence": 0.95
}

Batch Analysis

curl -X POST "http://localhost:8000/batch_analyze" \
     -H "Content-Type: application/json" \
     -d '{"texts": ["我很喜欢这个产品", "差评", "还不错"]}'

Response:

[
    {"label": "positive", "confidence": 0.95},
    {"label": "negative", "confidence": 0.87},
    {"label": "neutral", "confidence": 0.65}
]

API Documentation

Once the service is running, visit:

Monitoring

The service logs are stored in logs/app.log. Key metrics are exposed for Prometheus monitoring.

License

[Your License]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published