Commit
·
edbe376
1
Parent(s):
afbf5e5
feat: Added application file
Browse files- config/config.ini +2 -2
- src/api.py +1 -9
- src/data_loader.py +1 -1
config/config.ini
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
[data]
|
| 2 |
-
data_dir =
|
| 3 |
-
possible_labels_dir =
|
| 4 |
|
| 5 |
[model]
|
| 6 |
name = facebook/bart-large-mnli
|
|
|
|
| 1 |
[data]
|
| 2 |
+
data_dir = .\data\data.json
|
| 3 |
+
possible_labels_dir = .\data\possible_labels.json
|
| 4 |
|
| 5 |
[model]
|
| 6 |
name = facebook/bart-large-mnli
|
src/api.py
CHANGED
|
@@ -1,18 +1,13 @@
|
|
| 1 |
import configparser
|
| 2 |
|
| 3 |
from fastapi import FastAPI
|
| 4 |
-
from fastapi.middleware.cors import CORSMiddleware
|
| 5 |
from pydantic import BaseModel
|
| 6 |
from SentimentAndIntentionAnalysis import ZeroShotClassifier
|
| 7 |
from data_loader import *
|
| 8 |
|
| 9 |
# Initialize FastAPI app
|
| 10 |
app = FastAPI()
|
| 11 |
-
|
| 12 |
-
allow_origins=["http://localhost:8501"],
|
| 13 |
-
allow_credentials=True,
|
| 14 |
-
allow_methods=["*"],
|
| 15 |
-
allow_headers=["*"],)
|
| 16 |
#Get model_name, data_path and labels_path
|
| 17 |
model_name, data_path, labels_path = get_config()
|
| 18 |
|
|
@@ -33,8 +28,5 @@ def analyze_text(data: Text):
|
|
| 33 |
result = analyzer.analyze_text(data.text)
|
| 34 |
return AnalysisResult(sentiment=result["sentiment"], intention=result["intention"])
|
| 35 |
|
| 36 |
-
if __name__ == "__main__":
|
| 37 |
-
import uvicorn
|
| 38 |
-
uvicorn.run("api:app", host="0.0.0.0", port=8000, reload=True)
|
| 39 |
|
| 40 |
|
|
|
|
| 1 |
import configparser
|
| 2 |
|
| 3 |
from fastapi import FastAPI
|
|
|
|
| 4 |
from pydantic import BaseModel
|
| 5 |
from SentimentAndIntentionAnalysis import ZeroShotClassifier
|
| 6 |
from data_loader import *
|
| 7 |
|
| 8 |
# Initialize FastAPI app
|
| 9 |
app = FastAPI()
|
| 10 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
#Get model_name, data_path and labels_path
|
| 12 |
model_name, data_path, labels_path = get_config()
|
| 13 |
|
|
|
|
| 28 |
result = analyzer.analyze_text(data.text)
|
| 29 |
return AnalysisResult(sentiment=result["sentiment"], intention=result["intention"])
|
| 30 |
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
|
src/data_loader.py
CHANGED
|
@@ -3,7 +3,7 @@ import json
|
|
| 3 |
def get_config():
|
| 4 |
# Read config
|
| 5 |
config = configparser.ConfigParser()
|
| 6 |
-
config.read(r"
|
| 7 |
|
| 8 |
# Get model_name
|
| 9 |
model_name = config["model"]["name"]
|
|
|
|
| 3 |
def get_config():
|
| 4 |
# Read config
|
| 5 |
config = configparser.ConfigParser()
|
| 6 |
+
config.read(r".\config\config.ini")
|
| 7 |
|
| 8 |
# Get model_name
|
| 9 |
model_name = config["model"]["name"]
|