salma-api / app.py
TymaaHammouda's picture
Import and use SinaTools
beec65b
raw
history blame
811 Bytes
from fastapi import FastAPI
from sinatools.DataDownload.downloader import download_folder_from_hf
from sinatools.wsd.disambiguator import disambiguate
import os
app = FastAPI()
SINATOOLS_DIR = os.path.expanduser("~/.sinatools")
os.makedirs(SINATOOLS_DIR, exist_ok=True)
# Destination path
dest_path = os.path.join(SINATOOLS_DIR)
# Download explicitly to the expected path
download_folder_from_hf("SinaLab/ArabGlossBERT", "bert-base-arabertv02_22_May_2021_00h_allglosses_unused01")
download_folder_from_hf("SinaLab/ArabGlossBERT", "bert-base-arabertv02")
# download_file(url='https://sina.birzeit.edu/four_grams.pickle', dest_path=dest_path)
@app.get("/predict")
def greet_json():
salma_output = disambiguate('تمشيت بين الجداول والأنهار')
return {"output": salma_output}