Download src/api.py from kubrabuzlu/SentimentAndIntentionAnalysis: direct link, hf CLI and curl.
- Browser
- Download file 572 Bytes
-
https://huggingface.co/spaces/kubrabuzlu/SentimentAndIntentionAnalysis/resolve/main/src/api.py
- Command line
-
hf download hf://spaces/kubrabuzlu/SentimentAndIntentionAnalysis/src/api.py
-
curl -L -o api.py https://huggingface.co/spaces/kubrabuzlu/SentimentAndIntentionAnalysis/resolve/main/src/api.py
572 Bytes
| import configparser | |
| from fastapi import FastAPI | |
| from pydantic import BaseModel | |
| from .SentimentAndIntentionAnalysis import ZeroShotClassifier | |
| # Initialize FastAPI app | |
| app = FastAPI() | |
| # Create Analzer | |
| analyzer = ZeroShotClassifier(model_name='facebook/bart-large-mnli') | |
| class AnalysisResult(BaseModel): | |
| sentiment: str | |
| intention: str | |
| class Text(BaseModel): | |
| text: str | |
| def analyze_text(data: Text): | |
| result = analyzer.analyze_text(data.text) | |
| return AnalysisResult(sentiment=result["sentiment"], intention=result["intention"]) | |