Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
import pandas as pd
|
| 3 |
+
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
|
| 4 |
+
|
| 5 |
+
app = FastAPI()
|
| 6 |
+
|
| 7 |
+
def classify_string(message):
|
| 8 |
+
analyzer = SentimentIntensityAnalyzer()
|
| 9 |
+
return analyzer.polarity_scores(message)
|
| 10 |
+
|
| 11 |
+
@app.get("/")
|
| 12 |
+
def greet_json():
|
| 13 |
+
return {"Hello": "World!"}
|
| 14 |
+
|
| 15 |
+
@app.get("/sentiment")
|
| 16 |
+
def sentiment_analysis(message: str):
|
| 17 |
+
analyzer = SentimentIntensityAnalyzer()
|
| 18 |
+
return analyzer.polarity_scores(message)
|